Skip to main content

Null

Struct Null 

Source
pub struct Null { /* private fields */ }
Available on crate features test-util only.
Expand description

A Read and Write that does nothing.

Any data written to it is discarded and it never returns any data when read from. Intended for simple tests and examples only.

Implementations§

Source§

impl Null

Source

pub fn builder() -> NullBuilder

Starts building a new NullStream.

Source

pub fn new() -> Self

Creates a new NullStream with the default configuration.

Source

pub async fn read_at_most_into( &mut self, _len: usize, into: BytesBuf, ) -> Result<(usize, BytesBuf), Infallible>

Reads 0 bytes into the provided buffer, returning it as-is.

§Errors

This call never fails.

Source

pub async fn read_more_into( &mut self, into: BytesBuf, ) -> Result<(usize, BytesBuf), Infallible>

Reads 0 bytes into the provided buffer, returning it as-is.

§Errors

This call never fails.

Source

pub async fn read_any(&mut self) -> Result<BytesBuf, Infallible>

Reads 0 bytes.

§Errors

This call never fails.

Source

pub async fn write(&mut self, _sequence: BytesView) -> Result<(), Infallible>

“Writes” the provided data, discarding it.

§Errors

This call never fails.

Source

pub fn memory(&self) -> impl MemoryShared

Returns the memory provider that was configured in the builder.

Source

pub fn reserve(&self, min_bytes: usize) -> BytesBuf

Reserves at least min_bytes bytes of memory capacity.

Returns an empty BytesBuf that can be used to fill the reserved memory with data.

The memory provider may provide more memory than requested.

The memory reservation request will always be fulfilled, obtaining more memory from the operating system if necessary.

§Zero-sized reservations

Reserving zero bytes of memory is a valid operation and will return a BytesBuf with zero or more bytes of capacity.

§Panics

May panic if the operating system runs out of memory.

Trait Implementations§

Source§

impl Debug for Null

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Null

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl HasMemory for Null

Source§

fn memory(&self) -> impl MemoryShared

Returns a sharing-compatible memory provider. Read more
Source§

impl Memory for Null

Source§

fn reserve(&self, min_bytes: usize) -> BytesBuf

Reserves at least min_bytes bytes of memory capacity. Read more
Source§

impl Read for Null

Source§

type Error = Infallible

Type used to signal errors by the implementation of this trait.
Source§

async fn read_at_most_into( &mut self, len: usize, into: BytesBuf, ) -> Result<(usize, BytesBuf), Infallible>

Reads at most len bytes into the provided buffer. Read more
Source§

async fn read_more_into( &mut self, into: BytesBuf, ) -> Result<(usize, BytesBuf), Infallible>

Reads an unspecified number of bytes into the provided buffer. Read more
Source§

async fn read_any(&mut self) -> Result<BytesBuf, Infallible>

Reads an unspecified number of bytes as a new buffer. Read more
Source§

impl Write for Null

Source§

type Error = Infallible

Type used to signal errors by the implementation of this trait.
Source§

async fn write(&mut self, _sequence: BytesView) -> Result<(), Infallible>

Writes the provided byte sequence. Read more

Auto Trait Implementations§

§

impl Freeze for Null

§

impl !RefUnwindSafe for Null

§

impl Send for Null

§

impl Sync for Null

§

impl Unpin for Null

§

impl !UnwindSafe for Null

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ReadExt for T
where T: Read,

Source§

async fn read_at_most(&mut self, len: usize) -> Result<BytesView, Error>

Reads at most len bytes into a new buffer. Read more
Source§

async fn read_exactly(&mut self, len: usize) -> Result<BytesView, Error>

Reads exactly len bytes into a new buffer. Read more
Source§

async fn read_at_most_while<F>( &mut self, len: usize, inspect_fn: F, ) -> Result<(BytesView, BytesBuf), Error>

Conditionally reads at most len bytes into a new buffer. Read more
Source§

async fn read_at_most_into_while<F>( &mut self, len: usize, into: BytesBuf, inspect_fn: F, ) -> Result<(BytesView, BytesBuf), Error>

Conditionally reads at most len bytes into the provided buffer. Read more
Source§

fn into_futures_stream(self) -> Pin<Box<ReadAsFuturesStream<T>>>

Available on crate feature futures-stream only.
Transforms the Read into a futures::Stream. Read more
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.
Source§

impl<T> WriteExt for T
where T: Write,

Source§

async fn prepare_and_write<F, E>( &mut self, min_capacity: usize, prepare_fn: F, ) -> Result<(), Error>
where F: FnOnce(BytesBuf) -> Result<BytesView, E> + Send, E: Error + Send + Sync + 'static,

Provides a memory buffer to a callback, then writes the contents. Read more
Source§

impl<T> MemoryShared for T
where T: Memory + Send + Sync + 'static,