WriteOnce

Struct WriteOnce 

Source
pub struct WriteOnce<'a, S: Storage + ?Sized> { /* private fields */ }
Expand description

Only allows a single write into the storage. After that, no more writes are allowed.

This can be used for very low latency scenarios where processing the single read is more important than filling the entire storage with as much data as possible.

Implementations§

Source§

impl<'a, S: Storage + ?Sized> WriteOnce<'a, S>

Source

pub fn new(storage: &'a mut S) -> Self

Trait Implementations§

Source§

impl<S: Storage + ?Sized> Storage for WriteOnce<'_, S>

Source§

const SPECIALIZES_BYTES: bool = S::SPECIALIZES_BYTES

Source§

const SPECIALIZES_BYTES_MUT: bool = S::SPECIALIZES_BYTES_MUT

Source§

fn put_slice(&mut self, bytes: &[u8])

Writes a slice of bytes into the storage Read more
Source§

fn put_uninit_slice<F, Error>( &mut self, payload_len: usize, f: F, ) -> Result<bool, Error>
where F: FnOnce(&mut UninitSlice) -> Result<(), Error>,

Tries to write into a uninit slice for the current storage Read more
Source§

fn remaining_capacity(&self) -> usize

Returns the additional number of bytes that can be written to the storage
Source§

fn has_remaining_capacity(&self) -> bool

Returns true if the storage will accept any additional bytes
Source§

fn put_bytes(&mut self, bytes: Bytes)

Writes Bytes into the storage Read more
Source§

fn put_bytes_mut(&mut self, bytes: BytesMut)

Writes BytesMut into the storage Read more
Source§

fn put_chunk(&mut self, chunk: Chunk<'_>)

Writes a reader Chunk into the storage
Source§

fn with_write_limit(&mut self, max_len: usize) -> Limit<'_, Self>

Limits the number of bytes that can be written to the storage
Source§

fn track_write(&mut self) -> Tracked<'_, Self>

Tracks the number of bytes written to the storage
Source§

fn write_once(&mut self) -> WriteOnce<'_, Self>

Only allows a single write into the storage. After that, no more writes are allowed. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for WriteOnce<'a, S>
where S: ?Sized,

§

impl<'a, S> RefUnwindSafe for WriteOnce<'a, S>
where S: RefUnwindSafe + ?Sized,

§

impl<'a, S> Send for WriteOnce<'a, S>
where S: Send + ?Sized,

§

impl<'a, S> Sync for WriteOnce<'a, S>
where S: Sync + ?Sized,

§

impl<'a, S> Unpin for WriteOnce<'a, S>
where S: ?Sized,

§

impl<'a, S> !UnwindSafe for WriteOnce<'a, S>

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, 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, U> Upcast<T> for U
where T: UpcastFrom<U>,

Source§

fn upcast(self) -> T

Source§

impl<T, B> UpcastFrom<Counter<T, B>> for T

Source§

fn upcast_from(value: Counter<T, B>) -> T