Skip to main content

SingleOwnerChunk

Struct SingleOwnerChunk 

Source
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>

Source

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.

Source

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.

Source

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

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

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.

Source

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.

Source

pub const fn id(&self) -> B256

Get the ID of this chunk.

Source

pub const fn signature(&self) -> &Signature

Get the signature of this chunk.

Trait Implementations§

Source§

impl<'a, const BODY_SIZE: usize> Arbitrary<'a> for SingleOwnerChunk<BODY_SIZE>

Available on crate features arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<const BODY_SIZE: usize> BmtChunk for SingleOwnerChunk<BODY_SIZE>

Source§

fn span(&self) -> u64

Get the span of the chunk data
Source§

impl<const BODY_SIZE: usize> Chunk for SingleOwnerChunk<BODY_SIZE>

Source§

type Header = SingleOwnerChunkHeader

The header type for this chunk
Source§

fn address(&self) -> &ChunkAddress

Get the address of this chunk
Source§

fn data(&self) -> &Bytes

Get the raw data contained in this chunk
Source§

fn size(&self) -> usize

Get the total size of this chunk in bytes
Source§

fn header(&self) -> &Self::Header

Get the header for this chunk
Source§

fn verify(&self, expected: &ChunkAddress) -> Result<()>

Verify that this chunk matches an expected address
Source§

impl<const BODY_SIZE: usize> ChunkType for SingleOwnerChunk<BODY_SIZE>

Source§

const TYPE_ID: ChunkTypeId = super::type_id::ChunkTypeId::SINGLE_OWNER

The wire-level type identifier for this chunk type. Read more
Source§

const TYPE_NAME: &'static str = "single_owner"

Human-readable name for this chunk type. Read more
Source§

impl<const BODY_SIZE: usize> Clone for SingleOwnerChunk<BODY_SIZE>

Source§

fn clone(&self) -> SingleOwnerChunk<BODY_SIZE>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<const BODY_SIZE: usize> Debug for SingleOwnerChunk<BODY_SIZE>

Source§

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

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

impl<const BODY_SIZE: usize> Display for SingleOwnerChunk<BODY_SIZE>

Source§

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

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

impl<const BODY_SIZE: usize> Eq for SingleOwnerChunk<BODY_SIZE>

Source§

impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for AnyChunk<BODY_SIZE>

Source§

fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self

Converts to this type from the input type.
Source§

impl<const BODY_SIZE: usize> From<SingleOwnerChunk<BODY_SIZE>> for Bytes

Source§

fn from(chunk: SingleOwnerChunk<BODY_SIZE>) -> Self

Converts to this type from the input type.
Source§

impl<const BODY_SIZE: usize> PartialEq for SingleOwnerChunk<BODY_SIZE>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<const BODY_SIZE: usize> TryFrom<&[u8]> for SingleOwnerChunk<BODY_SIZE>

Source§

type Error = PrimitivesError

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

fn try_from(bytes: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl<const BODY_SIZE: usize> TryFrom<Bytes> for SingleOwnerChunk<BODY_SIZE>

Source§

type Error = PrimitivesError

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

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

Performs the conversion.

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ChunkSerialization for T
where T: Chunk,

Source§

fn serialize_with_prefix(&self) -> Bytes

Serialize this chunk with its type ID and version prefix
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
Source§

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

Source§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more