pub struct ByteStream { /* private fields */ }Expand description
An append-only byte buffer with terminal state and parked ranged reads.
Implementations§
Source§impl ByteStream
impl ByteStream
Sourcepub fn push(&self, bytes: &[u8]) -> bool
pub fn push(&self, bytes: &[u8]) -> bool
Append bytes and wake parked readers.
Returns false (dropping the bytes) if the stream is closed.
Sourcepub fn snapshot_at(&self, offset: u64, max: usize) -> ByteChunk
pub fn snapshot_at(&self, offset: u64, max: usize) -> ByteChunk
Non-blocking ranged read: whatever is available right now.
Sourcepub async fn read_at(&self, offset: u64, max: usize) -> ByteChunk
pub async fn read_at(&self, offset: u64, max: usize) -> ByteChunk
read(2): park until at least one byte past offset exists or
the stream is closed. Returns an empty chunk exactly at
end-of-stream.
Sourcepub async fn read_at_cancellable(
&self,
offset: u64,
max: usize,
token: &CancelToken,
) -> Result<ByteChunk, Cancelled>
pub async fn read_at_cancellable( &self, offset: u64, max: usize, token: &CancelToken, ) -> Result<ByteChunk, Cancelled>
ByteStream::read_at, cancellable.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ByteStream
impl RefUnwindSafe for ByteStream
impl Send for ByteStream
impl Sync for ByteStream
impl Unpin for ByteStream
impl UnsafeUnpin for ByteStream
impl UnwindSafe for ByteStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more