pub struct SingleOwnerChunk<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> { /* private fields */ }Expand description
A single-owner chunk with configurable body size.
This type represents a chunk of data that belongs to a specific owner and includes a digital signature proving ownership.
Implementations§
Source§impl<const BODY_SIZE: usize> SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> SingleOwnerChunk<BODY_SIZE>
Sourcepub fn new(
id: B256,
data: impl Into<Bytes>,
signer: &impl SignerSync,
) -> Result<Self>
pub fn new( id: B256, data: impl Into<Bytes>, signer: &impl SignerSync, ) -> Result<Self>
Create a new single-owner chunk with the given ID, data, and signer.
This function automatically calculates the span based on the data length and signs the chunk using the provided signer.
§Arguments
id- The unique identifier for this chunk.data- The raw data content to encapsulate in the chunk.signer- The signer to use for signing the chunk.
§Returns
A Result containing the new SingleOwnerChunk, or an error if creation fails.
Sourcepub fn with_signature(
id: B256,
signature: Signature,
data: impl Into<Bytes>,
) -> Result<Self>
pub fn with_signature( id: B256, signature: Signature, data: impl Into<Bytes>, ) -> Result<Self>
Create a new SingleOwnerChunk with a pre-signed signature.
This function is useful when the signature is already known, for example when retrieving a chunk from a database or when reconstructing after verification.
§Arguments
id- The unique identifier for this chunk.signature- The pre-computed signature.data- The raw data content to encapsulate in the chunk.
§Returns
A Result containing the new SingleOwnerChunk, or an error if creation fails.
Sourcepub fn new_dispersed_replica(
mined_byte: u8,
body: BmtBody<BODY_SIZE>,
) -> Result<Self>
pub fn new_dispersed_replica( mined_byte: u8, body: BmtBody<BODY_SIZE>, ) -> Result<Self>
Create a new SingleOwnerChunk as a dispersed replica.
§Arguments
mined_byte- The first byte of the chunk’s ID.body- The underlying BMT body containing the data and metadata.
Sourcepub const fn from_parts(
id: B256,
signature: Signature,
body: BmtBody<BODY_SIZE>,
) -> Self
pub const fn from_parts( id: B256, signature: Signature, body: BmtBody<BODY_SIZE>, ) -> Self
Create a SingleOwnerChunk from pre-computed parts.
This is an advanced method for reconstructing chunks from storage when you have all the individual components.
§Arguments
id- The chunk’s unique identifier.signature- The digital signature.body- The BMT body containing the data.
Sourcepub fn from_parts_with_caches(
id: B256,
signature: Signature,
body: BmtBody<BODY_SIZE>,
address: ChunkAddress,
owner: Address,
) -> Self
pub fn from_parts_with_caches( id: B256, signature: Signature, body: BmtBody<BODY_SIZE>, address: ChunkAddress, owner: Address, ) -> Self
Create a SingleOwnerChunk from pre-computed parts with cached address and owner.
This is an advanced method for reconstructing chunks when you also know the chunk address and owner address.
Sourcepub fn owner(&self) -> Result<Address, ChunkError>
pub fn owner(&self) -> Result<Address, ChunkError>
Get the owner’s address, derived from the signature.
This computes the owner’s address by recovering it from the signature and the signed data (the chunk’s ID and body hash). The result is cached on success for subsequent calls.
§Returns
The owner’s address as a 20-byte fixed array, or an error if signature recovery fails.
§Errors
Returns ChunkError::Signature if the signature recovery fails.
Trait Implementations§
Source§impl<'a, const BODY_SIZE: usize> Arbitrary<'a> for SingleOwnerChunk<BODY_SIZE>
Available on crate features arbitrary only.
impl<'a, const BODY_SIZE: usize> Arbitrary<'a> for SingleOwnerChunk<BODY_SIZE>
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<const BODY_SIZE: usize> BmtChunk for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> BmtChunk for SingleOwnerChunk<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Chunk for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Chunk for SingleOwnerChunk<BODY_SIZE>
Source§fn address(&self) -> &ChunkAddress
fn address(&self) -> &ChunkAddress
Source§impl<const BODY_SIZE: usize> ChunkType for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> ChunkType for SingleOwnerChunk<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Clone for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Clone for SingleOwnerChunk<BODY_SIZE>
Source§fn clone(&self) -> SingleOwnerChunk<BODY_SIZE>
fn clone(&self) -> SingleOwnerChunk<BODY_SIZE>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const BODY_SIZE: usize> Debug for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Debug for SingleOwnerChunk<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Display for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Display for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Eq for SingleOwnerChunk<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for AnyChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for AnyChunk<BODY_SIZE>
Source§fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self
fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self
Source§impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for Bytes
impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for Bytes
Source§fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self
fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self
Source§impl<const BODY_SIZE: usize> PartialEq for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> PartialEq for SingleOwnerChunk<BODY_SIZE>
Auto Trait Implementations§
impl<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> !Freeze for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> RefUnwindSafe for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Send for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Sync for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> Unpin for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> UnsafeUnpin for SingleOwnerChunk<BODY_SIZE>
impl<const BODY_SIZE: usize> UnwindSafe for SingleOwnerChunk<BODY_SIZE>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> ChunkSerialization for Twhere
T: Chunk,
impl<T> ChunkSerialization for Twhere
T: Chunk,
Source§fn serialize_with_prefix(&self) -> Bytes
fn serialize_with_prefix(&self) -> Bytes
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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