pub struct Immutable<T, H = NoHash> { /* private fields */ }Expand description
An Immutable<T, H> stores an immutable T plus various derived values.
One of the derived values is the hash of the encoded T, which has type H. H may be
NoHash if we do not care about this hash.
Implementations§
Source§impl<T, H: HashOrNoHash> Immutable<T, H>
impl<T, H: HashOrNoHash> Immutable<T, H>
Sourcepub fn from_parts(value: T, hash: H, encoded: Bytes) -> Self
pub fn from_parts(value: T, hash: H, encoded: Bytes) -> Self
Construct an Immutable<T, H> from a T, its hash and its encoding.
Sourcepub fn from_value_and_encoded(value: T, encoded: Bytes) -> Self
pub fn from_value_and_encoded(value: T, encoded: Bytes) -> Self
Construct an Immutable<T, H> from a T and its encoding.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the length of the encoding of the wrapped value.
Sourcepub fn into_value(self) -> T
pub fn into_value(self) -> T
Returns the wrapped value.
Sourcepub fn into_encoded(self) -> Bytes
pub fn into_encoded(self) -> Bytes
Returns the encoding of the wrapped value.
Sourcepub fn into_value_and_encoded(self) -> (T, Bytes)
pub fn into_value_and_encoded(self) -> (T, Bytes)
Returns the wrapped value and its encoding.
Sourcepub fn into_parts(self) -> (T, Bytes, H)
pub fn into_parts(self) -> (T, Bytes, H)
Returns the wrapped value, hash and its encoding.
Source§impl<T: Encode, H: HashOrNoHash> Immutable<T, H>
impl<T: Encode, H: HashOrNoHash> Immutable<T, H>
pub fn modify_and_encode(&mut self, f: impl FnOnce(&mut T))
Trait Implementations§
Source§impl<T: Decode, H: HashOrNoHash> Decode for Immutable<T, H>
impl<T: Decode, H: HashOrNoHash> Decode for Immutable<T, H>
Source§fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
fn decode<I: Input>(input: &mut I) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn skip<I: Input>(input: &mut I) -> Result<(), Error>
fn skip<I: Input>(input: &mut I) -> Result<(), Error>
Attempt to skip the encoded value from input. Read more
Source§fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<T, H> Encode for Immutable<T, H>
impl<T, H> Encode for Immutable<T, H>
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl From<&Immutable<WrappedWorkPackage<ImmutableWrap>, WorkPackageHash>> for WorkPackageOutline
impl From<&Immutable<WrappedWorkPackage<ImmutableWrap>, WorkPackageHash>> for WorkPackageOutline
Source§fn from(package: &ImmutableWorkPackage) -> Self
fn from(package: &ImmutableWorkPackage) -> Self
Converts to this type from the input type.
Source§impl<T: MaxEncodedLen, H> MaxEncodedLen for Immutable<T, H>
impl<T: MaxEncodedLen, H> MaxEncodedLen for Immutable<T, H>
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
Auto Trait Implementations§
impl<T, H = NoHash> !Freeze for Immutable<T, H>
impl<T, H> RefUnwindSafe for Immutable<T, H>where
T: RefUnwindSafe,
H: RefUnwindSafe,
impl<T, H> Send for Immutable<T, H>
impl<T, H> Sync for Immutable<T, H>
impl<T, H> Unpin for Immutable<T, H>
impl<T, H> UnsafeUnpin for Immutable<T, H>where
T: UnsafeUnpin,
H: UnsafeUnpin,
impl<T, H> UnwindSafe for Immutable<T, H>where
T: UnwindSafe,
H: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S> Codec for S
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> EncodeLike<&&T> for Twhere
T: Encode,
impl<T> EncodeLike<&T> for Twhere
T: Encode,
impl<T> EncodeLike<&mut T> for Twhere
T: Encode,
impl<T> EncodeLike<Arc<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Box<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Cow<'_, T>> for T
impl<T> EncodeLike<Rc<T>> for Twhere
T: Encode,
Source§impl<T> HashOrNoHash for T
impl<T> HashOrNoHash for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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