Struct smoldot_light::platform::with_buffers::ReadWriteAccess

source ·
pub struct ReadWriteAccess<'a, TNow>
where TNow: Clone,
{ /* private fields */ }
Expand description

Methods from Deref<Target = ReadWrite<TNow>>§

source

pub fn is_dead(&self) -> bool

Returns true if the connection should be considered dead. That is, both ReadWrite::expected_incoming_bytes is None and ReadWrite::write_bytes_queueable is None.

source

pub fn close_write(&mut self)

Sets the writing side of the connection to closed.

This is simply a shortcut for setting ReadWrite::write_bytes_queueable to None.

source

pub fn incoming_buffer_available(&self) -> usize

Returns the size of the data available in the incoming buffer.

source

pub fn discard_all_incoming(&mut self)

Discards all the incoming data. Updates ReadWrite::read_bytes and decreases ReadWrite::expected_incoming_bytes by the number of consumed bytes.

source

pub fn incoming_bytes_take( &mut self, num: usize, ) -> Result<Option<Vec<u8>>, IncomingBytesTakeError>

Extract a certain number of bytes from the read buffer.

On success, updates ReadWrite::read_bytes and decreases ReadWrite::expected_incoming_bytes by the number of consumed bytes.

If not enough bytes are available, returns None and sets ReadWrite::expected_incoming_bytes to the requested number of bytes.

source

pub fn incoming_bytes_take_array<const N: usize>( &mut self, ) -> Result<Option<[u8; N]>, IncomingBytesTakeError>

Same as ReadWrite::incoming_bytes_take_array, but reads a number of bytes as a compile-time constant.

source

pub fn incoming_bytes_take_leb128( &mut self, max_decoded_number: usize, ) -> Result<Option<usize>, IncomingBytesTakeLeb128Error>

Extract an LEB128-encoded number from the start of the read buffer.

On success, updates ReadWrite::read_bytes and decreases ReadWrite::expected_incoming_bytes by the number of consumed bytes.

If not enough bytes are available, returns None and sets ReadWrite::expected_incoming_bytes to the required number of bytes.

Must be passed the maximum value that this function can return on success. An error is returned if the value sent by the remote is higher than this maximum. This parameter, while not strictly necessary, is here for safety, as it is easy to forget to check the value against a maximum.

source

pub fn write_from_vec(&mut self, data: &mut Vec<u8>)

Copies as much as possible from the content of data to ReadWrite::write_buffers and updates ReadWrite::write_bytes_queued and ReadWrite::write_bytes_queueable. The bytes that have been written are removed from data.

This function is recommended only if the Vec is small.

source

pub fn write_from_vec_deque(&mut self, data: &mut VecDeque<u8>)

Copies as much as possible from the content of data to ReadWrite::write_buffers and updates ReadWrite::write_bytes_queued and ReadWrite::write_bytes_queueable. The bytes that have been written are removed from data.

source

pub fn write_out(&mut self, data: Vec<u8>)

Adds the data to ReadWrite::write_buffers, increases ReadWrite::write_bytes_queued, and decreases ReadWrite::write_bytes_queueable.

§Panic

Panics if data.len() > write_bytes_queueable. Panics if the writing side is closed and data isn’t empty.

source

pub fn wake_up_after(&mut self, after: &TNow)
where TNow: Clone + Ord,

Sets ReadWrite::wake_up_after to min(wake_up_after, after).

source

pub fn wake_up_asap(&mut self)
where TNow: Clone,

Trait Implementations§

source§

impl<'a, TNow> Deref for ReadWriteAccess<'a, TNow>
where TNow: Clone,

source§

type Target = ReadWrite<TNow>

The resulting type after dereferencing.
source§

fn deref(&self) -> &<ReadWriteAccess<'a, TNow> as Deref>::Target

Dereferences the value.
source§

impl<'a, TNow> DerefMut for ReadWriteAccess<'a, TNow>
where TNow: Clone,

source§

fn deref_mut(&mut self) -> &mut <ReadWriteAccess<'a, TNow> as Deref>::Target

Mutably dereferences the value.
source§

impl<'a, TNow> Drop for ReadWriteAccess<'a, TNow>
where TNow: Clone,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, TNow> Freeze for ReadWriteAccess<'a, TNow>
where TNow: Freeze,

§

impl<'a, TNow> RefUnwindSafe for ReadWriteAccess<'a, TNow>
where TNow: RefUnwindSafe,

§

impl<'a, TNow> Send for ReadWriteAccess<'a, TNow>
where TNow: Send,

§

impl<'a, TNow> Sync for ReadWriteAccess<'a, TNow>
where TNow: Sync,

§

impl<'a, TNow> Unpin for ReadWriteAccess<'a, TNow>
where TNow: Unpin,

§

impl<'a, TNow> !UnwindSafe for ReadWriteAccess<'a, TNow>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more