pub struct WriteStream<T> { /* private fields */ }Expand description
The write part of a stream.
Implementations§
Source§impl<T> WriteStream<T>
impl<T> WriteStream<T>
Sourcepub fn new() -> (WriteStream<T>, ReadStream<T>)
pub fn new() -> (WriteStream<T>, ReadStream<T>)
Create new stream pair.
Source§impl<T: Copy> WriteStream<T>
impl<T: Copy> WriteStream<T>
Sourcepub fn write_buf(&self) -> Result<BufferWriter<T>>
pub fn write_buf(&self) -> Result<BufferWriter<T>>
Return a BufferWriter for writing to the stream.
Ideally having a BufferWriter active on a stream should be prevented
statically, but I’ve not come up with a way to do that.
Having write_buf hold on to a mutable reference won’t work, because
streams are owned by blocks, and blocks need to be able to call their
own mutable methods.
BufferWriters do get an Arc to the circ buffer, though, so there should
never be more than four references:
- The source block.
- The destination block.
- The source
BufferWriter. - The destination
BufferReader.
So this function needs to be called when the refcount is 3 or lower.
Having more than four references is a definite coding bug, and hopefully
will be caught by MTGraph testing during development.
The above also goes for ReadStream::read_buf.
pub fn wait_for_write(&self, need: usize) -> bool
Trait Implementations§
Source§impl<T: Debug> Debug for WriteStream<T>
impl<T: Debug> Debug for WriteStream<T>
Source§impl<T> StreamReadSide for WriteStream<T>
impl<T> StreamReadSide for WriteStream<T>
type ReadSide = ReadStream<T>
Source§impl<T: Copy + Send + Sync> StreamWait for WriteStream<T>
impl<T: Copy + Send + Sync> StreamWait for WriteStream<T>
Auto Trait Implementations§
impl<T> Freeze for WriteStream<T>
impl<T> RefUnwindSafe for WriteStream<T>where
T: RefUnwindSafe,
impl<T> Send for WriteStream<T>
impl<T> Sync for WriteStream<T>
impl<T> Unpin for WriteStream<T>
impl<T> UnwindSafe for WriteStream<T>where
T: RefUnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more