Skip to content

Commit a599f53

Browse files
hbinachifflier
authored andcommitted
Add Send trait bound to create_reader so I can use this in async context
Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
1 parent 934258d commit a599f53

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/capture.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ pub trait Capture {
3333
pub fn create_reader<'b, R>(
3434
capacity: usize,
3535
mut reader: R,
36-
) -> Result<Box<dyn PcapReaderIterator + 'b>, PcapError<&'static [u8]>>
36+
) -> Result<Box<dyn PcapReaderIterator + Send + 'b>, PcapError<&'static [u8]>>
3737
where
38-
R: Read + 'b,
38+
R: Read + Send + 'b,
3939
{
4040
let mut buffer = Buffer::with_capacity(capacity);
4141
let sz = reader.read(buffer.space()).or(Err(PcapError::ReadError))?;
@@ -46,11 +46,11 @@ where
4646
// just check that first block is a valid one
4747
if parse_sectionheaderblock(buffer.data()).is_ok() {
4848
return PcapNGReader::from_buffer(buffer, reader)
49-
.map(|r| Box::new(r) as Box<dyn PcapReaderIterator>);
49+
.map(|r| Box::new(r) as Box<dyn PcapReaderIterator + Send>);
5050
}
5151
match parse_pcap_header(buffer.data()) {
5252
Ok(_) => LegacyPcapReader::from_buffer(buffer, reader)
53-
.map(|r| Box::new(r) as Box<dyn PcapReaderIterator>),
53+
.map(|r| Box::new(r) as Box<dyn PcapReaderIterator + Send>),
5454
Err(nom::Err::Incomplete(Needed::Size(n))) => Err(PcapError::Incomplete(n.into())),
5555
Err(nom::Err::Incomplete(Needed::Unknown)) => Err(PcapError::Incomplete(0)),
5656
_ => Err(PcapError::HeaderNotRecognized),

0 commit comments

Comments
 (0)