Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Send marker to trait objects in debian-packaging/src/deb/reader.rs #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
target/
*.swp
29 changes: 16 additions & 13 deletions debian-packaging/src/deb/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
},
};

fn reader_from_filename(extension: &str, data: std::io::Cursor<Vec<u8>>) -> Result<Box<dyn Read>> {
fn reader_from_filename(
extension: &str,
data: std::io::Cursor<Vec<u8>>,
) -> Result<Box<dyn Read + Send>> {
match extension {
"" => Ok(Box::new(data)),
".gz" => Ok(Box::new(libflate::gzip::Decoder::new(data)?)),
Expand All @@ -29,7 +32,7 @@
fn reader_from_filename_async(
extension: &str,
data: futures::io::Cursor<Vec<u8>>,
) -> Result<Box<dyn futures::AsyncRead + Unpin>> {
) -> Result<Box<dyn futures::AsyncRead + Unpin + Send>> {
match extension {
"" => Ok(Box::new(data)),
".gz" => Ok(Box::new(
Expand All @@ -52,11 +55,11 @@
/// 1. `debian-binary` holding the version of the binary package format.
/// 2. `control.tar` holding package metadata.
/// 3. `data.tar[.<ext>]` holding file content.
pub struct BinaryPackageReader<R: Read> {
pub struct BinaryPackageReader<R: Read + Send> {
archive: ar::Archive<R>,
}

impl<R: Read> BinaryPackageReader<R> {
impl<R: Read + Send> BinaryPackageReader<R> {
/// Construct a new instance from a reader.
pub fn new(reader: R) -> Result<Self> {
Ok(Self {
Expand Down Expand Up @@ -127,11 +130,11 @@

/// A reader for `control.tar` files.
pub struct ControlTarReader {
archive: tar::Archive<Box<dyn Read>>,
archive: tar::Archive<Box<dyn Read + Send>>,
}

impl Deref for ControlTarReader {
type Target = tar::Archive<Box<dyn Read>>;
type Target = tar::Archive<Box<dyn Read + Send>>;

fn deref(&self) -> &Self::Target {
&self.archive
Expand Down Expand Up @@ -162,7 +165,7 @@
/// Ideally this type wouldn't exist. It is a glorified wrapper around
/// [tar::Entries] that is needed to placate the borrow checker.
pub struct ControlTarEntries<'a> {
entries: tar::Entries<'a, Box<dyn Read>>,
entries: tar::Entries<'a, Box<dyn Read + Send>>,
}

impl<'a> Iterator for ControlTarEntries<'a> {
Expand All @@ -182,24 +185,24 @@
/// Facilitates access to the raw [tar::Entry] as well as for obtaining a higher
/// level type that decodes known files within `control.tar` files.
pub struct ControlTarEntry<'a> {
inner: tar::Entry<'a, Box<dyn Read>>,
inner: tar::Entry<'a, Box<dyn Read + Send>>,
}

impl<'a> Deref for ControlTarEntry<'a> {
type Target = tar::Entry<'a, Box<dyn Read>>;
type Target = tar::Entry<'a, Box<dyn Read + Send>>;

fn deref(&self) -> &Self::Target {
&self.inner
}
}

impl<'a> DerefMut for ControlTarEntry<'a> {

Check warning on line 199 in debian-packaging/src/deb/reader.rs

View workflow job for this annotation

GitHub Actions / build-and-test (stable, ubuntu-22.04, x86_64-unknown-linux-gnu)

warning: the following explicit lifetimes could be elided: 'a --> debian-packaging/src/deb/reader.rs:199:6 | 199 | impl<'a> DerefMut for ControlTarEntry<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 199 - impl<'a> DerefMut for ControlTarEntry<'a> { 199 + impl DerefMut for ControlTarEntry<'_> { |

Check warning on line 199 in debian-packaging/src/deb/reader.rs

View workflow job for this annotation

GitHub Actions / build-and-test (beta, ubuntu-22.04, x86_64-unknown-linux-gnu)

warning: the following explicit lifetimes could be elided: 'a --> debian-packaging/src/deb/reader.rs:199:6 | 199 | impl<'a> DerefMut for ControlTarEntry<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 199 - impl<'a> DerefMut for ControlTarEntry<'a> { 199 + impl DerefMut for ControlTarEntry<'_> { |
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}

impl<'a> ControlTarEntry<'a> {

Check warning on line 205 in debian-packaging/src/deb/reader.rs

View workflow job for this annotation

GitHub Actions / build-and-test (stable, ubuntu-22.04, x86_64-unknown-linux-gnu)

warning: the following explicit lifetimes could be elided: 'a --> debian-packaging/src/deb/reader.rs:205:6 | 205 | impl<'a> ControlTarEntry<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 205 - impl<'a> ControlTarEntry<'a> { 205 + impl ControlTarEntry<'_> { |

Check warning on line 205 in debian-packaging/src/deb/reader.rs

View workflow job for this annotation

GitHub Actions / build-and-test (beta, ubuntu-22.04, x86_64-unknown-linux-gnu)

warning: the following explicit lifetimes could be elided: 'a --> debian-packaging/src/deb/reader.rs:205:6 | 205 | impl<'a> ControlTarEntry<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 205 - impl<'a> ControlTarEntry<'a> { 205 + impl ControlTarEntry<'_> { |
/// Attempt to convert this tar entry to a [ControlTarFile].
///
///
Expand Down Expand Up @@ -270,11 +273,11 @@

/// A reader for `data.tar` files.
pub struct DataTarReader {
archive: async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin>>,
archive: async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin + Send>>,
}

impl Deref for DataTarReader {
type Target = async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin>>;
type Target = async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin + Send>>;

fn deref(&self) -> &Self::Target {
&self.archive
Expand All @@ -289,13 +292,13 @@

impl DataTarReader {
/// Obtain the inner [async_tar::Archive] to which this instance is bound.
pub fn into_inner(self) -> async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin>> {
pub fn into_inner(self) -> async_tar::Archive<Box<dyn futures::io::AsyncRead + Unpin + Send>> {
self.archive
}
}

/// Resolve the `control` file from the `control.tar` file within a `.deb` archive.
pub fn resolve_control_file(reader: impl Read) -> Result<BinaryPackageControlFile<'static>> {
pub fn resolve_control_file(reader: impl Read + Send) -> Result<BinaryPackageControlFile<'static>> {
let mut reader = BinaryPackageReader::new(reader)?;

while let Some(entry) = reader.next_entry() {
Expand Down
Loading