pub struct StampIndex { /* private fields */ }Expand description
A stamp index representing the position of a chunk within a batch.
The stamp index consists of two components:
bucket: The collision bucket determined by the chunk’s address (also called “x”)index: The position within that bucket (also called “y”)
§Implementation Note
The exact encoding of the stamp index into a single value is implementation-specific and not defined by the Swarm specifications. This implementation encodes the index as a 64-bit value by concatenating the bucket (high 32 bits) and position (low 32 bits) in big-endian format. Other implementations may use different encodings.
Implementations§
Source§impl StampIndex
impl StampIndex
Sourcepub const fn encode(&self) -> u64
pub const fn encode(&self) -> u64
Encodes the stamp index as a 64-bit value for use in stamp digest calculation.
§Encoding Format
The encoding concatenates bucket (4 bytes BE) and index (4 bytes BE):
| bucket (32 bits) | index (32 bits) |
| high 32 bits | low 32 bits |§Implementation Note
This encoding is implementation-specific and not defined by the Swarm specifications. The Swarm protocol only specifies that the stamp contains bucket and index values; the exact wire format for the combined index used in signature computation is left to implementations.
Sourcepub const fn decode(encoded: u64) -> Self
pub const fn decode(encoded: u64) -> Self
Decodes a stamp index from a 64-bit encoded value.
See encode for the encoding format.
Sourcepub const fn to_be_bytes(&self) -> [u8; 8]
pub const fn to_be_bytes(&self) -> [u8; 8]
Converts the index to big-endian bytes (8 bytes total).
Sourcepub const fn from_be_bytes(bytes: [u8; 8]) -> Self
pub const fn from_be_bytes(bytes: [u8; 8]) -> Self
Creates a stamp index from big-endian bytes.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for StampIndex
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for StampIndex
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 Clone for StampIndex
impl Clone for StampIndex
Source§fn clone(&self) -> StampIndex
fn clone(&self) -> StampIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StampIndex
Source§impl Debug for StampIndex
impl Debug for StampIndex
Source§impl<'de> Deserialize<'de> for StampIndex
impl<'de> Deserialize<'de> for StampIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for StampIndex
Source§impl From<StampIndex> for (u32, u32)
impl From<StampIndex> for (u32, u32)
Source§fn from(idx: StampIndex) -> Self
fn from(idx: StampIndex) -> Self
Source§impl Hash for StampIndex
impl Hash for StampIndex
Source§impl PartialEq for StampIndex
impl PartialEq for StampIndex
Source§fn eq(&self, other: &StampIndex) -> bool
fn eq(&self, other: &StampIndex) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for StampIndex
impl Serialize for StampIndex
impl StructuralPartialEq for StampIndex
Auto Trait Implementations§
impl Freeze for StampIndex
impl RefUnwindSafe for StampIndex
impl Send for StampIndex
impl Sync for StampIndex
impl Unpin for StampIndex
impl UnsafeUnpin for StampIndex
impl UnwindSafe for StampIndex
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<'de, T> BorrowedRpcObject<'de> for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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