Struct Piece

Source
pub struct Piece(/* private fields */);
Expand description

A piece of archival history.

This version is allocated on the heap, for stack-allocated piece see PieceArray.

Internally piece contains a record and corresponding proof that together with segment root of the segment this piece belongs to can be used to verify that a piece belongs to the actual archival history of the blockchain.

Implementations§

Source§

impl Piece

Source

pub const SIZE: usize = 1_048_896usize

Size of a piece (in bytes).

Source

pub fn to_shared(self) -> Self

Ensure piece contains cheaply cloneable shared data.

Internally piece uses CoW mechanism and can store either mutable owned data or data that is cheap to clone, calling this method will ensure further clones will not result in additional memory allocations.

Methods from Deref<Target = PieceArray>§

Source

pub const SIZE: usize = 1_048_896usize

Source

pub fn is_valid(&self, segment_root: &SegmentRoot, position: u32) -> bool

Validate proof embedded within a piece produced by the archiver

Source

pub fn split(&self) -> (&Record, &RecordRoot, &RecordChunksRoot, &RecordProof)

Split piece into underlying components.

Source

pub fn split_mut( &mut self, ) -> (&mut Record, &mut RecordRoot, &mut RecordChunksRoot, &mut RecordProof)

Split piece into underlying mutable components.

Source

pub fn record(&self) -> &Record

Record contained within a piece.

Source

pub fn record_mut(&mut self) -> &mut Record

Mutable record contained within a piece.

Source

pub fn root(&self) -> &RecordRoot

Root contained within a piece.

Source

pub fn root_mut(&mut self) -> &mut RecordRoot

Mutable root contained within a piece.

Source

pub fn parity_chunks_root(&self) -> &RecordChunksRoot

Parity chunks root contained within a piece.

Source

pub fn parity_chunks_root_mut(&mut self) -> &mut RecordChunksRoot

Mutable parity chunks root contained within a piece.

Source

pub fn proof(&self) -> &RecordProof

Proof contained within a piece.

Source

pub fn proof_mut(&mut self) -> &mut RecordProof

Mutable proof contained within a piece.

Trait Implementations§

Source§

impl AsMut<[u8]> for Piece

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for Piece

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Piece

Source§

fn clone(&self) -> Piece

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Piece

Source§

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

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

impl Decode for Piece

Source§

fn decode<I: Input>(input: &mut I) -> Result<Self, Error>

Attempt to deserialise the value from 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
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl Default for Piece

Source§

fn default() -> Self

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

impl Deref for Piece

Source§

type Target = PieceArray

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Piece

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for Piece

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Encode for Piece

Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encode_to<O: Output + ?Sized>(&self, output: &mut O)

Convert self to a slice and append it to the destination.
Source§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
Source§

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

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
Source§

impl From<&PieceArray> for Piece

Source§

fn from(value: &PieceArray) -> Self

Converts to this type from the input type.
Source§

impl From<Piece> for Vec<u8>

Source§

fn from(piece: Piece) -> Self

Converts to this type from the input type.
Source§

impl Hash for Piece

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Piece

Source§

fn eq(&self, other: &Piece) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Piece

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&[u8]> for Piece

Source§

type Error = ()

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

fn try_from(slice: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Bytes> for Piece

Source§

type Error = ()

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

fn try_from(bytes: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<BytesMut> for Piece

Source§

type Error = ()

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

fn try_from(bytes: BytesMut) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for Piece

Source§

type Error = ()

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

fn try_from(vec: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TypeInfo for Piece

Source§

type Identity = Piece

The type identifying for which type info is provided. Read more
Source§

fn type_info() -> Type

Returns the static type identifier for Self.
Source§

impl EncodeLike for Piece

Source§

impl Eq for Piece

Source§

impl StructuralPartialEq for Piece

Auto Trait Implementations§

§

impl !Freeze for Piece

§

impl RefUnwindSafe for Piece

§

impl Send for Piece

§

impl Sync for Piece

§

impl Unpin for Piece

§

impl UnwindSafe for Piece

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
§

impl<T, U> AsByteSlice<T> for U
where T: ToByteSlice, U: AsRef<[T]> + ?Sized,

§

fn as_byte_slice(&self) -> &[u8]

§

impl<T, U> AsMutByteSlice<T> for U
where T: ToMutByteSlice, U: AsMut<[T]> + ?Sized,

§

fn as_mut_byte_slice(&mut self) -> &mut [u8]

§

impl<U> AsMutSliceOf for U
where U: AsMut<[u8]> + ?Sized,

§

fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error>
where T: FromByteSlice,

§

impl<U> AsSliceOf for U
where U: AsRef<[u8]> + ?Sized,

§

fn as_slice_of<T>(&self) -> Result<&[T], Error>
where T: FromByteSlice,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> DecodeAll for T
where T: Decode,

§

fn decode_all(input: &mut &[u8]) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

impl<T> DecodeLimit for T
where T: Decode,

§

fn decode_all_with_depth_limit( limit: u32, input: &mut &[u8], ) -> Result<T, Error>

Decode Self and consume all of the given input data. Read more
§

fn decode_with_depth_limit<I>(limit: u32, input: &mut I) -> Result<T, Error>
where I: Input,

Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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
§

impl<T> KeyedVec for T
where T: Codec,

§

fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8>

Return an encoding of Self prepended by given slice.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<S> Codec for S
where S: Decode + Encode,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> EncodeLike<&&T> for T
where T: Encode,

§

impl<T> EncodeLike<&T> for T
where T: Encode,

§

impl<T> EncodeLike<&mut T> for T
where T: Encode,

§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

§

impl<T> EncodeLike<Box<T>> for T
where T: Encode,

§

impl<T> EncodeLike<Cow<'_, T>> for T
where T: ToOwned + Encode,

§

impl<T> EncodeLike<Rc<T>> for T
where T: Encode,

§

impl<S> FullCodec for S
where S: Decode + FullEncode,

§

impl<S> FullEncode for S
where S: Encode + EncodeLike,

§

impl<T> JsonSchemaMaybe for T

§

impl<T> StaticTypeInfo for T
where T: TypeInfo + 'static,