Struct hyper_staticfile::FileBytesStream 
source · pub struct FileBytesStream { /* private fields */ }Expand description
Wraps a tokio::fs::File, and implements a stream of Bytess.
Implementations§
source§impl FileBytesStream
 
impl FileBytesStream
sourcepub fn new(file: File) -> FileBytesStream
 
pub fn new(file: File) -> FileBytesStream
Create a new stream from the given file.
sourcepub fn new_with_limit(file: File, limit: u64) -> FileBytesStream
 
pub fn new_with_limit(file: File, limit: u64) -> FileBytesStream
Create a new stream from the given file, reading up to limit bytes.
Examples found in repository?
src/util/file_bytes_stream.rs (line 98)
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
    pub fn new(file: File, range: HttpRange) -> FileBytesStreamRange {
        FileBytesStreamRange {
            file_stream: FileBytesStream::new_with_limit(file, range.length),
            seek_state: FileSeekState::NeedSeek,
            start_offset: range.start,
        }
    }
    fn without_initial_range(file: File) -> FileBytesStreamRange {
        FileBytesStreamRange {
            file_stream: FileBytesStream::new_with_limit(file, 0),
            seek_state: FileSeekState::NeedSeek,
            start_offset: 0,
        }
    }More examples
src/util/file_response_builder.rs (line 259)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
    pub fn build(
        &self,
        file: File,
        metadata: Metadata,
        content_type: String,
    ) -> Result<Response<Body>> {
        let mut res = ResponseBuilder::new();
        // Set `Last-Modified` and check `If-Modified-Since`.
        let modified = metadata.modified().ok().filter(|v| {
            v.duration_since(UNIX_EPOCH)
                .ok()
                .filter(|v| v >= &MIN_VALID_MTIME)
                .is_some()
        });
        // default to false when specified, either the etag or last_modified will set
        // it to true later.
        let mut range_cond_ok = self.if_range.is_none();
        if let Some(modified) = modified {
            if let Ok(modified_unix) = modified.duration_since(UNIX_EPOCH) {
                // Compare whole seconds only, because the HTTP date-time
                // format also does not contain a fractional part.
                if let Some(Ok(ims_unix)) =
                    self.if_modified_since.map(|v| v.duration_since(UNIX_EPOCH))
                {
                    if modified_unix.as_secs() <= ims_unix.as_secs() {
                        return ResponseBuilder::new()
                            .status(StatusCode::NOT_MODIFIED)
                            .body(Body::empty());
                    }
                }
                let etag = format!(
                    "W/\"{0:x}-{1:x}.{2:x}\"",
                    metadata.len(),
                    modified_unix.as_secs(),
                    modified_unix.subsec_nanos()
                );
                if let Some(ref v) = self.if_range {
                    if *v == etag {
                        range_cond_ok = true;
                    }
                }
                res = res.header(header::ETAG, etag);
            }
            let last_modified_formatted = httpdate::fmt_http_date(modified);
            if let Some(ref v) = self.if_range {
                if *v == last_modified_formatted {
                    range_cond_ok = true;
                }
            }
            res = res
                .header(header::LAST_MODIFIED, last_modified_formatted)
                .header(header::ACCEPT_RANGES, "bytes");
        }
        // Build remaining headers.
        if let Some(seconds) = self.cache_headers {
            res = res.header(
                header::CACHE_CONTROL,
                format!("public, max-age={}", seconds),
            );
        }
        if self.is_head {
            res = res.header(header::CONTENT_LENGTH, format!("{}", metadata.len()));
            return res.status(StatusCode::OK).body(Body::empty());
        }
        let ranges = self.range.as_ref().filter(|_| range_cond_ok).and_then(|r| {
            match HttpRange::parse(r, metadata.len()) {
                Ok(r) => Some(Ok(r)),
                Err(HttpRangeParseError::NoOverlap) => Some(Err(())),
                Err(HttpRangeParseError::InvalidRange) => None,
            }
        });
        if let Some(ranges) = ranges {
            let ranges = match ranges {
                Ok(r) => r,
                Err(()) => {
                    return res
                        .status(StatusCode::RANGE_NOT_SATISFIABLE)
                        .body(Body::empty());
                }
            };
            if ranges.len() == 1 {
                let single_span = ranges[0];
                res = res
                    .header(
                        header::CONTENT_RANGE,
                        content_range_header(&single_span, metadata.len()),
                    )
                    .header(header::CONTENT_LENGTH, format!("{}", single_span.length));
                let body_stream = FileBytesStreamRange::new(file, single_span);
                return res
                    .status(StatusCode::PARTIAL_CONTENT)
                    .body(body_stream.into_body());
            } else if ranges.len() > 1 {
                let mut boundary_tmp = [0u8; BOUNDARY_LENGTH];
                let mut rng = thread_rng();
                for v in boundary_tmp.iter_mut() {
                    // won't panic since BOUNDARY_CHARS is non-empty
                    *v = *BOUNDARY_CHARS.choose(&mut rng).unwrap();
                }
                // won't panic because boundary_tmp is guaranteed to be all ASCII
                let boundary = std::str::from_utf8(&boundary_tmp[..]).unwrap().to_string();
                res = res.header(
                    hyper::header::CONTENT_TYPE,
                    format!("multipart/byteranges; boundary={}", boundary),
                );
                let mut body_stream =
                    FileBytesStreamMultiRange::new(file, ranges, boundary, metadata.len());
                if !content_type.is_empty() {
                    body_stream.set_content_type(&content_type);
                }
                res = res.header(
                    hyper::header::CONTENT_LENGTH,
                    format!("{}", body_stream.compute_length()),
                );
                return res
                    .status(StatusCode::PARTIAL_CONTENT)
                    .body(body_stream.into_body());
            }
        }
        res = res.header(header::CONTENT_LENGTH, format!("{}", metadata.len()));
        if !content_type.is_empty() {
            res = res.header(header::CONTENT_TYPE, content_type);
        }
        // Stream the body.
        res.status(StatusCode::OK)
            .body(FileBytesStream::new_with_limit(file, metadata.len()).into_body())
    }source§impl FileBytesStream
 
impl FileBytesStream
sourcepub fn into_body(self) -> Body
 
pub fn into_body(self) -> Body
Create a Hyper Body from this stream.
Examples found in repository?
src/util/file_response_builder.rs (line 259)
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
    pub fn build(
        &self,
        file: File,
        metadata: Metadata,
        content_type: String,
    ) -> Result<Response<Body>> {
        let mut res = ResponseBuilder::new();
        // Set `Last-Modified` and check `If-Modified-Since`.
        let modified = metadata.modified().ok().filter(|v| {
            v.duration_since(UNIX_EPOCH)
                .ok()
                .filter(|v| v >= &MIN_VALID_MTIME)
                .is_some()
        });
        // default to false when specified, either the etag or last_modified will set
        // it to true later.
        let mut range_cond_ok = self.if_range.is_none();
        if let Some(modified) = modified {
            if let Ok(modified_unix) = modified.duration_since(UNIX_EPOCH) {
                // Compare whole seconds only, because the HTTP date-time
                // format also does not contain a fractional part.
                if let Some(Ok(ims_unix)) =
                    self.if_modified_since.map(|v| v.duration_since(UNIX_EPOCH))
                {
                    if modified_unix.as_secs() <= ims_unix.as_secs() {
                        return ResponseBuilder::new()
                            .status(StatusCode::NOT_MODIFIED)
                            .body(Body::empty());
                    }
                }
                let etag = format!(
                    "W/\"{0:x}-{1:x}.{2:x}\"",
                    metadata.len(),
                    modified_unix.as_secs(),
                    modified_unix.subsec_nanos()
                );
                if let Some(ref v) = self.if_range {
                    if *v == etag {
                        range_cond_ok = true;
                    }
                }
                res = res.header(header::ETAG, etag);
            }
            let last_modified_formatted = httpdate::fmt_http_date(modified);
            if let Some(ref v) = self.if_range {
                if *v == last_modified_formatted {
                    range_cond_ok = true;
                }
            }
            res = res
                .header(header::LAST_MODIFIED, last_modified_formatted)
                .header(header::ACCEPT_RANGES, "bytes");
        }
        // Build remaining headers.
        if let Some(seconds) = self.cache_headers {
            res = res.header(
                header::CACHE_CONTROL,
                format!("public, max-age={}", seconds),
            );
        }
        if self.is_head {
            res = res.header(header::CONTENT_LENGTH, format!("{}", metadata.len()));
            return res.status(StatusCode::OK).body(Body::empty());
        }
        let ranges = self.range.as_ref().filter(|_| range_cond_ok).and_then(|r| {
            match HttpRange::parse(r, metadata.len()) {
                Ok(r) => Some(Ok(r)),
                Err(HttpRangeParseError::NoOverlap) => Some(Err(())),
                Err(HttpRangeParseError::InvalidRange) => None,
            }
        });
        if let Some(ranges) = ranges {
            let ranges = match ranges {
                Ok(r) => r,
                Err(()) => {
                    return res
                        .status(StatusCode::RANGE_NOT_SATISFIABLE)
                        .body(Body::empty());
                }
            };
            if ranges.len() == 1 {
                let single_span = ranges[0];
                res = res
                    .header(
                        header::CONTENT_RANGE,
                        content_range_header(&single_span, metadata.len()),
                    )
                    .header(header::CONTENT_LENGTH, format!("{}", single_span.length));
                let body_stream = FileBytesStreamRange::new(file, single_span);
                return res
                    .status(StatusCode::PARTIAL_CONTENT)
                    .body(body_stream.into_body());
            } else if ranges.len() > 1 {
                let mut boundary_tmp = [0u8; BOUNDARY_LENGTH];
                let mut rng = thread_rng();
                for v in boundary_tmp.iter_mut() {
                    // won't panic since BOUNDARY_CHARS is non-empty
                    *v = *BOUNDARY_CHARS.choose(&mut rng).unwrap();
                }
                // won't panic because boundary_tmp is guaranteed to be all ASCII
                let boundary = std::str::from_utf8(&boundary_tmp[..]).unwrap().to_string();
                res = res.header(
                    hyper::header::CONTENT_TYPE,
                    format!("multipart/byteranges; boundary={}", boundary),
                );
                let mut body_stream =
                    FileBytesStreamMultiRange::new(file, ranges, boundary, metadata.len());
                if !content_type.is_empty() {
                    body_stream.set_content_type(&content_type);
                }
                res = res.header(
                    hyper::header::CONTENT_LENGTH,
                    format!("{}", body_stream.compute_length()),
                );
                return res
                    .status(StatusCode::PARTIAL_CONTENT)
                    .body(body_stream.into_body());
            }
        }
        res = res.header(header::CONTENT_LENGTH, format!("{}", metadata.len()));
        if !content_type.is_empty() {
            res = res.header(header::CONTENT_TYPE, content_type);
        }
        // Stream the body.
        res.status(StatusCode::OK)
            .body(FileBytesStream::new_with_limit(file, metadata.len()).into_body())
    }Trait Implementations§
source§impl Stream for FileBytesStream
 
impl Stream for FileBytesStream
Auto Trait Implementations§
impl !RefUnwindSafe for FileBytesStream
impl Send for FileBytesStream
impl Sync for FileBytesStream
impl Unpin for FileBytesStream
impl UnwindSafe for FileBytesStream
Blanket Implementations§
source§impl<T> Instrument for T
 
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> StreamExt for Twhere
    T: Stream + ?Sized,
 
impl<T> StreamExt for Twhere
    T: Stream + ?Sized,
source§fn next(&mut self) -> Next<'_, Self>where
    Self: Unpin,
 
fn next(&mut self) -> Next<'_, Self>where
    Self: Unpin,
Creates a future that resolves to the next item in the stream. Read more
source§fn into_future(self) -> StreamFuture<Self>where
    Self: Sized + Unpin,
 
fn into_future(self) -> StreamFuture<Self>where
    Self: Sized + Unpin,
source§fn map<T, F>(self, f: F) -> Map<Self, F>where
    F: FnMut(Self::Item) -> T,
    Self: Sized,
 
fn map<T, F>(self, f: F) -> Map<Self, F>where
    F: FnMut(Self::Item) -> T,
    Self: Sized,
Maps this stream’s items to a different type, returning a new stream of
the resulting type. Read more
source§fn enumerate(self) -> Enumerate<Self>where
    Self: Sized,
 
fn enumerate(self) -> Enumerate<Self>where
    Self: Sized,
Creates a stream which gives the current iteration count as well as
the next value. Read more
source§fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
 
fn filter<Fut, F>(self, f: F) -> Filter<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
Filters the values produced by this stream according to the provided
asynchronous predicate. Read more
source§fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = Option<T>>,
    Self: Sized,
 
fn filter_map<Fut, T, F>(self, f: F) -> FilterMap<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = Option<T>>,
    Self: Sized,
Filters the values produced by this stream while simultaneously mapping
them to a different type according to the provided asynchronous closure. Read more
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future,
    Self: Sized,
 
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future,
    Self: Sized,
Computes from this stream’s items new items of a different type using
an asynchronous closure. Read more
source§fn collect<C>(self) -> Collect<Self, C>where
    C: Default + Extend<Self::Item>,
    Self: Sized,
 
fn collect<C>(self) -> Collect<Self, C>where
    C: Default + Extend<Self::Item>,
    Self: Sized,
Transforms a stream into a collection, returning a
future representing the result of that computation. Read more
source§fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where
    FromA: Default + Extend<A>,
    FromB: Default + Extend<B>,
    Self: Sized + Stream<Item = (A, B)>,
 
fn unzip<A, B, FromA, FromB>(self) -> Unzip<Self, FromA, FromB>where
    FromA: Default + Extend<A>,
    FromB: Default + Extend<B>,
    Self: Sized + Stream<Item = (A, B)>,
Converts a stream of pairs into a future, which
resolves to pair of containers. Read more
source§fn concat(self) -> Concat<Self>where
    Self: Sized,
    Self::Item: Extend<<Self::Item as IntoIterator>::Item> + IntoIterator + Default,
 
fn concat(self) -> Concat<Self>where
    Self: Sized,
    Self::Item: Extend<<Self::Item as IntoIterator>::Item> + IntoIterator + Default,
Concatenate all items of a stream into a single extendable
destination, returning a future representing the end result. Read more
source§fn count(self) -> Count<Self>where
    Self: Sized,
 
fn count(self) -> Count<Self>where
    Self: Sized,
Drives the stream to completion, counting the number of items. Read more
source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where
    F: FnMut(T, Self::Item) -> Fut,
    Fut: Future<Output = T>,
    Self: Sized,
 
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>where
    F: FnMut(T, Self::Item) -> Fut,
    Fut: Future<Output = T>,
    Self: Sized,
Execute an accumulating asynchronous computation over a stream,
collecting all the values into one final result. Read more
source§fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
 
fn any<Fut, F>(self, f: F) -> Any<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
Execute predicate over asynchronous stream, and return 
true if any element in stream satisfied a predicate. Read moresource§fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
 
fn all<Fut, F>(self, f: F) -> All<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
Execute predicate over asynchronous stream, and return 
true if all element in stream satisfied a predicate. Read moresource§fn flatten(self) -> Flatten<Self>where
    Self::Item: Stream,
    Self: Sized,
 
fn flatten(self) -> Flatten<Self>where
    Self::Item: Stream,
    Self: Sized,
Flattens a stream of streams into just one continuous stream. Read more
source§fn flatten_unordered(
    self,
    limit: impl Into<Option<usize>>
) -> FlattenUnordered<Self>where
    Self::Item: Stream + Unpin,
    Self: Sized,
 
fn flatten_unordered(
    self,
    limit: impl Into<Option<usize>>
) -> FlattenUnordered<Self>where
    Self::Item: Stream + Unpin,
    Self: Sized,
Flattens a stream of streams into just one continuous stream. Polls
inner streams concurrently. Read more
source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where
    F: FnMut(Self::Item) -> U,
    U: Stream,
    Self: Sized,
 
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where
    F: FnMut(Self::Item) -> U,
    U: Stream,
    Self: Sized,
source§fn flat_map_unordered<U, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> FlatMapUnordered<Self, U, F>where
    U: Stream + Unpin,
    F: FnMut(Self::Item) -> U,
    Self: Sized,
 
fn flat_map_unordered<U, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> FlatMapUnordered<Self, U, F>where
    U: Stream + Unpin,
    F: FnMut(Self::Item) -> U,
    Self: Sized,
Maps a stream like 
StreamExt::map but flattens nested Streams
and polls them concurrently, yielding items in any order, as they made
available. Read moresource§fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where
    F: FnMut(&mut S, Self::Item) -> Fut,
    Fut: Future<Output = Option<B>>,
    Self: Sized,
 
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>where
    F: FnMut(&mut S, Self::Item) -> Fut,
    Fut: Future<Output = Option<B>>,
    Self: Sized,
Combinator similar to 
StreamExt::fold that holds internal state
and produces a new stream. Read moresource§fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
 
fn skip_while<Fut, F>(self, f: F) -> SkipWhile<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
Skip elements on this stream while the provided asynchronous predicate
resolves to 
true. Read moresource§fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
 
fn take_while<Fut, F>(self, f: F) -> TakeWhile<Self, Fut, F>where
    F: FnMut(&Self::Item) -> Fut,
    Fut: Future<Output = bool>,
    Self: Sized,
Take elements from this stream while the provided asynchronous predicate
resolves to 
true. Read moresource§fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where
    Fut: Future,
    Self: Sized,
 
fn take_until<Fut>(self, fut: Fut) -> TakeUntil<Self, Fut>where
    Fut: Future,
    Self: Sized,
Take elements from this stream until the provided future resolves. Read more
source§fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = ()>,
    Self: Sized,
 
fn for_each<Fut, F>(self, f: F) -> ForEach<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = ()>,
    Self: Sized,
Runs this stream to completion, executing the provided asynchronous
closure for each element on the stream. Read more
source§fn for_each_concurrent<Fut, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> ForEachConcurrent<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = ()>,
    Self: Sized,
 
fn for_each_concurrent<Fut, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> ForEachConcurrent<Self, Fut, F>where
    F: FnMut(Self::Item) -> Fut,
    Fut: Future<Output = ()>,
    Self: Sized,
Runs this stream to completion, executing the provided asynchronous
closure for each element on the stream concurrently as elements become
available. Read more
source§fn take(self, n: usize) -> Take<Self>where
    Self: Sized,
 
fn take(self, n: usize) -> Take<Self>where
    Self: Sized,
Creates a new stream of at most 
n items of the underlying stream. Read moresource§fn skip(self, n: usize) -> Skip<Self>where
    Self: Sized,
 
fn skip(self, n: usize) -> Skip<Self>where
    Self: Sized,
Creates a new stream which skips 
n items of the underlying stream. Read moresource§fn catch_unwind(self) -> CatchUnwind<Self>where
    Self: Sized + UnwindSafe,
 
fn catch_unwind(self) -> CatchUnwind<Self>where
    Self: Sized + UnwindSafe,
Catches unwinding panics while polling the stream. Read more
source§fn boxed<'a>(
    self
) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>where
    Self: 'a + Sized + Send,
 
fn boxed<'a>(
    self
) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>where
    Self: 'a + Sized + Send,
Wrap the stream in a Box, pinning it. Read more
source§fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>where
    Self: 'a + Sized,
 
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>where
    Self: 'a + Sized,
Wrap the stream in a Box, pinning it. Read more
source§fn buffered(self, n: usize) -> Buffered<Self>where
    Self::Item: Future,
    Self: Sized,
 
fn buffered(self, n: usize) -> Buffered<Self>where
    Self::Item: Future,
    Self: Sized,
An adaptor for creating a buffered list of pending futures. Read more
source§fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>where
    Self::Item: Future,
    Self: Sized,
 
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>where
    Self::Item: Future,
    Self: Sized,
An adaptor for creating a buffered list of pending futures (unordered). Read more
source§fn zip<St>(self, other: St) -> Zip<Self, St>where
    St: Stream,
    Self: Sized,
 
fn zip<St>(self, other: St) -> Zip<Self, St>where
    St: Stream,
    Self: Sized,
An adapter for zipping two streams together. Read more
source§fn chain<St>(self, other: St) -> Chain<Self, St>where
    St: Stream<Item = Self::Item>,
    Self: Sized,
 
fn chain<St>(self, other: St) -> Chain<Self, St>where
    St: Stream<Item = Self::Item>,
    Self: Sized,
Adapter for chaining two streams. Read more
source§fn peekable(self) -> Peekable<Self>where
    Self: Sized,
 
fn peekable(self) -> Peekable<Self>where
    Self: Sized,
Creates a new stream which exposes a 
peek method. Read moresource§fn chunks(self, capacity: usize) -> Chunks<Self>where
    Self: Sized,
 
fn chunks(self, capacity: usize) -> Chunks<Self>where
    Self: Sized,
An adaptor for chunking up items of the stream inside a vector. Read more
source§fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
    Self: Sized,
 
fn ready_chunks(self, capacity: usize) -> ReadyChunks<Self>where
    Self: Sized,
An adaptor for chunking up ready items of the stream inside a vector. Read more
source§fn inspect<F>(self, f: F) -> Inspect<Self, F>where
    F: FnMut(&Self::Item),
    Self: Sized,
 
fn inspect<F>(self, f: F) -> Inspect<Self, F>where
    F: FnMut(&Self::Item),
    Self: Sized,
Do something with each item of this stream, afterwards passing it on. Read more
source§fn left_stream<B>(self) -> Either<Self, B>where
    B: Stream<Item = Self::Item>,
    Self: Sized,
 
fn left_stream<B>(self) -> Either<Self, B>where
    B: Stream<Item = Self::Item>,
    Self: Sized,
source§fn right_stream<B>(self) -> Either<B, Self>where
    B: Stream<Item = Self::Item>,
    Self: Sized,
 
fn right_stream<B>(self) -> Either<B, Self>where
    B: Stream<Item = Self::Item>,
    Self: Sized,
source§fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
    Self: Unpin,
 
fn poll_next_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>where
    Self: Unpin,
A convenience method for calling [
Stream::poll_next] on Unpin
stream types.source§fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
    Self: Unpin + FusedStream,
 
fn select_next_some(&mut self) -> SelectNextSome<'_, Self>where
    Self: Unpin + FusedStream,
source§impl<S> TryStreamExt for Swhere
    S: TryStream + ?Sized,
 
impl<S> TryStreamExt for Swhere
    S: TryStream + ?Sized,
source§fn err_into<E>(self) -> ErrInto<Self, E>where
    Self: Sized,
    Self::Error: Into<E>,
 
fn err_into<E>(self) -> ErrInto<Self, E>where
    Self: Sized,
    Self::Error: Into<E>,
Wraps the current stream in a new stream which converts the error type
into the one provided. Read more
source§fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>where
    Self: Sized,
    F: FnMut(Self::Ok) -> T,
 
fn map_ok<T, F>(self, f: F) -> MapOk<Self, F>where
    Self: Sized,
    F: FnMut(Self::Ok) -> T,
Wraps the current stream in a new stream which maps the success value
using the provided closure. Read more
source§fn map_err<E, F>(self, f: F) -> MapErr<Self, F>where
    Self: Sized,
    F: FnMut(Self::Error) -> E,
 
fn map_err<E, F>(self, f: F) -> MapErr<Self, F>where
    Self: Sized,
    F: FnMut(Self::Error) -> E,
Wraps the current stream in a new stream which maps the error value
using the provided closure. Read more
source§fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: TryFuture<Error = Self::Error>,
    Self: Sized,
 
fn and_then<Fut, F>(self, f: F) -> AndThen<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: TryFuture<Error = Self::Error>,
    Self: Sized,
Chain on a computation for when a value is ready, passing the successful
results to the provided closure 
f. Read moresource§fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>where
    F: FnMut(Self::Error) -> Fut,
    Fut: TryFuture<Ok = Self::Ok>,
    Self: Sized,
 
fn or_else<Fut, F>(self, f: F) -> OrElse<Self, Fut, F>where
    F: FnMut(Self::Error) -> Fut,
    Fut: TryFuture<Ok = Self::Ok>,
    Self: Sized,
Chain on a computation for when an error happens, passing the
erroneous result to the provided closure 
f. Read moresource§fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>where
    F: FnMut(&Self::Ok),
    Self: Sized,
 
fn inspect_ok<F>(self, f: F) -> InspectOk<Self, F>where
    F: FnMut(&Self::Ok),
    Self: Sized,
Do something with the success value of this stream, afterwards passing
it on. Read more
source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>where
    F: FnMut(&Self::Error),
    Self: Sized,
 
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>where
    F: FnMut(&Self::Error),
    Self: Sized,
Do something with the error value of this stream, afterwards passing it on. Read more
source§fn into_stream(self) -> IntoStream<Self>where
    Self: Sized,
 
fn into_stream(self) -> IntoStream<Self>where
    Self: Sized,
source§fn try_next(&mut self) -> TryNext<'_, Self>where
    Self: Unpin,
 
fn try_next(&mut self) -> TryNext<'_, Self>where
    Self: Unpin,
Creates a future that attempts to resolve the next item in the stream.
If an error is encountered before the next item, the error is returned
instead. Read more
source§fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: TryFuture<Ok = (), Error = Self::Error>,
    Self: Sized,
 
fn try_for_each<Fut, F>(self, f: F) -> TryForEach<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: TryFuture<Ok = (), Error = Self::Error>,
    Self: Sized,
Attempts to run this stream to completion, executing the provided
asynchronous closure for each element on the stream. Read more
source§fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>where
    F: FnMut(&Self::Ok) -> Fut,
    Fut: TryFuture<Ok = bool, Error = Self::Error>,
    Self: Sized,
 
fn try_skip_while<Fut, F>(self, f: F) -> TrySkipWhile<Self, Fut, F>where
    F: FnMut(&Self::Ok) -> Fut,
    Fut: TryFuture<Ok = bool, Error = Self::Error>,
    Self: Sized,
Skip elements on this stream while the provided asynchronous predicate
resolves to 
true. Read moresource§fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>where
    F: FnMut(&Self::Ok) -> Fut,
    Fut: TryFuture<Ok = bool, Error = Self::Error>,
    Self: Sized,
 
fn try_take_while<Fut, F>(self, f: F) -> TryTakeWhile<Self, Fut, F>where
    F: FnMut(&Self::Ok) -> Fut,
    Fut: TryFuture<Ok = bool, Error = Self::Error>,
    Self: Sized,
Take elements on this stream while the provided asynchronous predicate
resolves to 
true. Read moresource§fn try_for_each_concurrent<Fut, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> TryForEachConcurrent<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: Future<Output = Result<(), Self::Error>>,
    Self: Sized,
 
fn try_for_each_concurrent<Fut, F>(
    self,
    limit: impl Into<Option<usize>>,
    f: F
) -> TryForEachConcurrent<Self, Fut, F>where
    F: FnMut(Self::Ok) -> Fut,
    Fut: Future<Output = Result<(), Self::Error>>,
    Self: Sized,
Attempts to run this stream to completion, executing the provided asynchronous
closure for each element on the stream concurrently as elements become
available, exiting as soon as an error occurs. Read more
source§fn try_collect<C>(self) -> TryCollect<Self, C>where
    C: Default + Extend<Self::Ok>,
    Self: Sized,
 
fn try_collect<C>(self) -> TryCollect<Self, C>where
    C: Default + Extend<Self::Ok>,
    Self: Sized,
Attempt to transform a stream into a collection,
returning a future representing the result of that computation. Read more
source§fn try_chunks(self, capacity: usize) -> TryChunks<Self>where
    Self: Sized,
 
fn try_chunks(self, capacity: usize) -> TryChunks<Self>where
    Self: Sized,
An adaptor for chunking up successful items of the stream inside a vector. Read more
source§fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>where
    Fut: Future<Output = bool>,
    F: FnMut(&Self::Ok) -> Fut,
    Self: Sized,
 
fn try_filter<Fut, F>(self, f: F) -> TryFilter<Self, Fut, F>where
    Fut: Future<Output = bool>,
    F: FnMut(&Self::Ok) -> Fut,
    Self: Sized,
Attempt to filter the values produced by this stream according to the
provided asynchronous closure. Read more
source§fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>where
    Fut: TryFuture<Ok = Option<T>, Error = Self::Error>,
    F: FnMut(Self::Ok) -> Fut,
    Self: Sized,
 
fn try_filter_map<Fut, F, T>(self, f: F) -> TryFilterMap<Self, Fut, F>where
    Fut: TryFuture<Ok = Option<T>, Error = Self::Error>,
    F: FnMut(Self::Ok) -> Fut,
    Self: Sized,
Attempt to filter the values produced by this stream while
simultaneously mapping them to a different type according to the
provided asynchronous closure. Read more
source§fn try_flatten(self) -> TryFlatten<Self>where
    Self::Ok: TryStream,
    <Self::Ok as TryStream>::Error: From<Self::Error>,
    Self: Sized,
 
fn try_flatten(self) -> TryFlatten<Self>where
    Self::Ok: TryStream,
    <Self::Ok as TryStream>::Error: From<Self::Error>,
    Self: Sized,
Flattens a stream of streams into just one continuous stream. Read more
source§fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>where
    F: FnMut(T, Self::Ok) -> Fut,
    Fut: TryFuture<Ok = T, Error = Self::Error>,
    Self: Sized,
 
fn try_fold<T, Fut, F>(self, init: T, f: F) -> TryFold<Self, Fut, T, F>where
    F: FnMut(T, Self::Ok) -> Fut,
    Fut: TryFuture<Ok = T, Error = Self::Error>,
    Self: Sized,
Attempt to execute an accumulating asynchronous computation over a
stream, collecting all the values into one final result. Read more
source§fn try_concat(self) -> TryConcat<Self>where
    Self: Sized,
    Self::Ok: Extend<<Self::Ok as IntoIterator>::Item> + IntoIterator + Default,
 
fn try_concat(self) -> TryConcat<Self>where
    Self: Sized,
    Self::Ok: Extend<<Self::Ok as IntoIterator>::Item> + IntoIterator + Default,
Attempt to concatenate all items of a stream into a single
extendable destination, returning a future representing the end result. Read more
source§fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>where
    Self::Ok: TryFuture<Error = Self::Error>,
    Self: Sized,
 
fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>where
    Self::Ok: TryFuture<Error = Self::Error>,
    Self: Sized,
Attempt to execute several futures from a stream concurrently (unordered). Read more
source§fn try_buffered(self, n: usize) -> TryBuffered<Self>where
    Self::Ok: TryFuture<Error = Self::Error>,
    Self: Sized,
 
fn try_buffered(self, n: usize) -> TryBuffered<Self>where
    Self::Ok: TryFuture<Error = Self::Error>,
    Self: Sized,
Attempt to execute several futures from a stream concurrently. Read more