Struct ps_datachunk::owned::OwnedDataChunk

source ·
pub struct OwnedDataChunk { /* private fields */ }
Expand description

represents an owned chunk of data

Implementations§

source§

impl OwnedDataChunk

source

pub fn data_ref(&self) -> &[u8]

source

pub fn hash_ref(&self) -> &[u8]

source

pub fn hash(&self) -> Arc<Hash>

source

pub fn from_parts(data: Vec<u8>, hash: Arc<Hash>) -> Self

Creates an OwnedDataChunk from its constituent parts

§Safety
  • hash must be the hash of data
  • use from_data() if you cannot ensure this
source

pub fn from_data(data: Vec<u8>) -> Self

calculates the hash of data and returns an OwnedDataChunk

source

pub fn from_data_ref_and_hash(data: &[u8], hash: Arc<Hash>) -> Self

creates an OwnedDataChunk with given data and hash

source

pub fn from_data_ref(data: &[u8]) -> Self

creates an OwnedDataChunk with given data

source

pub fn serialize_into(self) -> Vec<u8>

converts this OwnedDataChunk into a Vec<u8>

  • extends self.hash
  • returns self.data
source

pub fn serialize(&self) -> Vec<u8>

serializes this OwnedDataChunk into a newly allocated Vec<u8>

  • allocated a new Vec<u8>
  • copies self.data into the new Vec<u8>
  • copies self.hash into the new Vec<u8>
  • returns the new Vec<u8>
source

pub fn deserialize_from(data: Vec<u8>) -> Result<Self>

  • converts a Vec<u8> into an OwnedDataChunk
  • performs hash validation
source

pub fn deserialize(data: &[u8]) -> Result<Self>

Copies data into a new Vec<u8> and deserializes it into an OwnedDataChunk.

source

pub fn decrypt_bytes( encrypted: &[u8], key: &[u8], compressor: &Compressor, ) -> Result<Self>

Decrypts into an OwnedDataChunk with the given key

  • performs hash validation
  • fails if key not correct
source

pub fn decrypt(&self, key: &[u8], compressor: &Compressor) -> Result<Self>

Decrypts an OwnedDataChunk with the given key.

  • performs hash validation
  • fails if key not correct
source

pub fn encrypt_serialized_bytes( bytes: &[u8], compressor: &Compressor, ) -> Result<EncryptedDataChunk>

Encrypts a serialized DataChunk.

source

pub fn encrypt(&self, compressor: &Compressor) -> Result<EncryptedDataChunk>

Encrypts this DataChunk.

source

pub fn encrypt_mut( &mut self, compressor: &Compressor, ) -> Result<EncryptedDataChunk>

Encrypts this DataChunk.

  • optimized by using self.data as the serialization buffer

Trait Implementations§

source§

impl Clone for OwnedDataChunk

source§

fn clone(&self) -> OwnedDataChunk

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 DataChunkTrait for OwnedDataChunk

source§

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

source§

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

source§

fn hash(&self) -> HashCow<'_>

source§

fn encrypt(&self, compressor: &Compressor) -> Result<EncryptedDataChunk>

source§

fn decrypt(&self, key: &[u8], compressor: &Compressor) -> Result<OwnedDataChunk>

source§

fn to_datachunk(&self) -> DataChunk<'_>

source§

fn align(&self) -> AlignedDataChunk

source§

fn borrow(&self) -> BorrowedDataChunk<'_>

source§

fn to_owned(&self) -> OwnedDataChunk

source§

fn try_as<T: Archive>(&self) -> Result<TypedDataChunk<'_, T>>
where T::Archived: for<'a> CheckBytes<DefaultValidator<'a>>,

source§

impl Debug for OwnedDataChunk

source§

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

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

impl From<&OwnedDataChunk> for AlignedDataChunk

source§

fn from(value: &OwnedDataChunk) -> Self

Converts to this type from the input type.
source§

impl<'lt> From<DataChunk<'lt>> for OwnedDataChunk

source§

fn from(value: DataChunk<'lt>) -> Self

Converts to this type from the input type.
source§

impl<'lt> From<OwnedDataChunk> for DataChunk<'lt>

source§

fn from(chunk: OwnedDataChunk) -> Self

Converts to this type from the input type.
source§

impl Hash for OwnedDataChunk

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 Into<OwnedDataChunk> for &AlignedDataChunk

source§

fn into(self) -> OwnedDataChunk

Converts this type into the (usually inferred) input type.
source§

impl Ord for OwnedDataChunk

source§

fn cmp(&self, other: &OwnedDataChunk) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for OwnedDataChunk

source§

fn eq(&self, other: &OwnedDataChunk) -> 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 PartialOrd for OwnedDataChunk

source§

fn partial_cmp(&self, other: &OwnedDataChunk) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for OwnedDataChunk

source§

impl StructuralPartialEq for OwnedDataChunk

Auto Trait Implementations§

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

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

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

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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.