pub trait DataChunkwhere
Self: Sized,{
// Required methods
fn data_ref(&self) -> &[u8] ⓘ;
fn hash_ref(&self) -> &Hash;
// Provided methods
fn hash(&self) -> Hash { ... }
fn encrypt(&self) -> Result<EncryptedDataChunk> { ... }
fn decrypt(&self, key: &Hash) -> Result<SerializedDataChunk> { ... }
fn borrow(&self) -> BorrowedDataChunk<'_> { ... }
fn serialize(&self) -> Result<SerializedDataChunk> { ... }
fn into_bytes(self) -> Bytes { ... }
fn into_owned(self) -> OwnedDataChunk { ... }
fn try_as<T: Archive>(self) -> Result<TypedDataChunk<Self, T>>
where T::Archived: for<'a> CheckBytes<HighValidator<'a, Error>> { ... }
}Expand description
Represents any representation of a chunk of data.
§Invariants
Implementers must treat the bytes and hash exposed through &self as immutable and stable.
In practice this means:
- Repeated calls to
Self::data_refmust point to the same logical bytes whileselfis borrowed. - Repeated calls to
Self::hash_refmust return the hash for those same bytes. - Neither value may change through interior mutability while
selfis borrowed.
TypedDataChunk relies on this contract for its unchecked deref fast path.
Required Methods§
Sourcefn hash_ref(&self) -> &Hash
fn hash_ref(&self) -> &Hash
Returns a stable view of the hash corresponding to Self::data_ref.
Provided Methods§
fn hash(&self) -> Hash
fn encrypt(&self) -> Result<EncryptedDataChunk>
fn decrypt(&self, key: &Hash) -> Result<SerializedDataChunk>
fn borrow(&self) -> BorrowedDataChunk<'_>
fn serialize(&self) -> Result<SerializedDataChunk>
Sourcefn into_bytes(self) -> Bytes
fn into_bytes(self) -> Bytes
Sourcefn into_owned(self) -> OwnedDataChunk
fn into_owned(self) -> OwnedDataChunk
Copies this DataChunk into a new OwnedDataChunk.
fn try_as<T: Archive>(self) -> Result<TypedDataChunk<Self, T>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.