Skip to main content

DecodeSlot

Struct DecodeSlot 

Source
pub struct DecodeSlot<T> { /* private fields */ }
Available on crate feature serde only.
Expand description

Re-export of the nextjson format-neutral contracts used by tzcraft.

Available as tzcraft::codec::NsonSerialize and friends so downstream code can write tzcraft::codec::nextencode(...) without naming nextjson directly. Safe caller-provided storage used by NsonDeserialize::nextdecode_into.

The value starts uninitialized, but unlike a public MaybeUninit<T> contract it cannot be read before a successful write. Incorrect third-party implementations therefore cannot cause undefined behavior in safe code.

Implementations§

Source§

impl<T> DecodeSlot<T>

Source

pub const fn new() -> DecodeSlot<T>

Create an empty nextdecode slot.

Source

pub fn write(&mut self, value: T)

Replace the slot contents with a fully initialized value.

Source

pub fn take(&mut self) -> Option<T>

Remove and return the initialized value, if present.

Source

pub fn is_initialized(&self) -> bool

Return whether the slot currently contains a value.

Trait Implementations§

Source§

impl<T> Default for DecodeSlot<T>

Source§

fn default() -> DecodeSlot<T>

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

Auto Trait Implementations§

§

impl<T> Freeze for DecodeSlot<T>
where Option<T>: Freeze,

§

impl<T> RefUnwindSafe for DecodeSlot<T>

§

impl<T> Send for DecodeSlot<T>
where Option<T>: Send,

§

impl<T> Sync for DecodeSlot<T>
where Option<T>: Sync,

§

impl<T> Unpin for DecodeSlot<T>
where Option<T>: Unpin,

§

impl<T> UnsafeUnpin for DecodeSlot<T>
where Option<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for DecodeSlot<T>
where Option<T>: UnwindSafe,

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 = !

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.