Struct ps_datachunk::OwnedDataChunk
source · pub struct OwnedDataChunk {
pub hash: [u8; 50],
pub data: Vec<u8>,
}
Expand description
represents an owned chunk of data
Fields§
§hash: [u8; 50]
§data: Vec<u8>
Implementations§
source§impl OwnedDataChunk
impl OwnedDataChunk
sourcepub fn serialize_into(self) -> Vec<u8>
pub fn serialize_into(self) -> Vec<u8>
converts this OwnedDataChunk
into a Vec<u8>
- extends
self.hash
- returns
self.data
sourcepub fn serialize(&self) -> Vec<u8>
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 newVec<u8>
- copies
self.hash
into the newVec<u8>
- returns the new
Vec<u8>
sourcepub fn deserialize_from(data: Vec<u8>) -> Result<Self, PsDataChunkError>
pub fn deserialize_from(data: Vec<u8>) -> Result<Self, PsDataChunkError>
- converts a
Vec<u8>
into anOwnedDataChunk
- performs hash validation
sourcepub fn deserialize(data: &[u8]) -> Result<Self, PsDataChunkError>
pub fn deserialize(data: &[u8]) -> Result<Self, PsDataChunkError>
Copies data
into a new Vec<u8>
and deserializes it into an OwnedDataChunk
.
sourcepub fn decrypt_bytes(
encrypted: &[u8],
key: &[u8],
compressor: &Compressor,
) -> Result<Self, PsDataChunkError>
pub fn decrypt_bytes( encrypted: &[u8], key: &[u8], compressor: &Compressor, ) -> Result<Self, PsDataChunkError>
Decrypts into an OwnedDataChunk
with the given key
- performs hash validation
- fails if
key
not correct
sourcepub fn decrypt(
&self,
key: &[u8],
compressor: &Compressor,
) -> Result<Self, PsDataChunkError>
pub fn decrypt( &self, key: &[u8], compressor: &Compressor, ) -> Result<Self, PsDataChunkError>
Decrypts an OwnedDataChunk
with the given key
.
- performs hash validation
- fails if
key
not correct
sourcepub fn encrypt_bytes(
bytes: &[u8],
compressor: &Compressor,
) -> Result<EncryptedDataChunk, PsDataChunkError>
pub fn encrypt_bytes( bytes: &[u8], compressor: &Compressor, ) -> Result<EncryptedDataChunk, PsDataChunkError>
Encrypts a serialized DataChunk.
sourcepub fn encrypt(
&self,
compressor: &Compressor,
) -> Result<EncryptedDataChunk, PsDataChunkError>
pub fn encrypt( &self, compressor: &Compressor, ) -> Result<EncryptedDataChunk, PsDataChunkError>
Encrypts this DataChunk.
sourcepub fn encrypt_mut(
&mut self,
compressor: &Compressor,
) -> Result<EncryptedDataChunk, PsDataChunkError>
pub fn encrypt_mut( &mut self, compressor: &Compressor, ) -> Result<EncryptedDataChunk, PsDataChunkError>
Encrypts this DataChunk.
- optimized by using
self.data
as the serialization buffer
Trait Implementations§
source§impl Archive for OwnedDataChunk
impl Archive for OwnedDataChunk
§type Archived = ArchivedOwnedDataChunk
type Archived = ArchivedOwnedDataChunk
The archived representation of this type. Read more
§type Resolver = OwnedDataChunkResolver
type Resolver = OwnedDataChunkResolver
The resolver for this type. It must contain all the additional information from serializing
needed to make the archived type from the normal type.
source§impl Clone for OwnedDataChunk
impl Clone for OwnedDataChunk
source§fn clone(&self) -> OwnedDataChunk
fn clone(&self) -> OwnedDataChunk
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for OwnedDataChunk
impl Debug for OwnedDataChunk
source§impl From<&OwnedDataChunk> for AlignedDataChunk
impl From<&OwnedDataChunk> for AlignedDataChunk
source§fn from(value: &OwnedDataChunk) -> Self
fn from(value: &OwnedDataChunk) -> Self
Converts to this type from the input type.
source§impl Hash for OwnedDataChunk
impl Hash for OwnedDataChunk
source§impl<'lt> Into<DataChunk<'lt>> for OwnedDataChunk
impl<'lt> Into<DataChunk<'lt>> for OwnedDataChunk
source§impl Into<OwnedDataChunk> for AlignedDataChunk
impl Into<OwnedDataChunk> for AlignedDataChunk
source§fn into(self) -> OwnedDataChunk
fn into(self) -> OwnedDataChunk
Converts this type into the (usually inferred) input type.
source§impl<'lt> Into<OwnedDataChunk> for DataChunk<'lt>
impl<'lt> Into<OwnedDataChunk> for DataChunk<'lt>
source§fn into(self) -> OwnedDataChunk
fn into(self) -> OwnedDataChunk
Converts this type into the (usually inferred) input type.
source§impl Ord for OwnedDataChunk
impl Ord for OwnedDataChunk
source§fn cmp(&self, other: &OwnedDataChunk) -> Ordering
fn cmp(&self, other: &OwnedDataChunk) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for OwnedDataChunk
impl PartialEq for OwnedDataChunk
source§fn eq(&self, other: &OwnedDataChunk) -> bool
fn eq(&self, other: &OwnedDataChunk) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for OwnedDataChunk
impl PartialOrd for OwnedDataChunk
source§fn partial_cmp(&self, other: &OwnedDataChunk) -> Option<Ordering>
fn partial_cmp(&self, other: &OwnedDataChunk) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for OwnedDataChunk
impl StructuralPartialEq for OwnedDataChunk
Auto Trait Implementations§
impl Freeze for OwnedDataChunk
impl RefUnwindSafe for OwnedDataChunk
impl Send for OwnedDataChunk
impl Sync for OwnedDataChunk
impl Unpin for OwnedDataChunk
impl UnwindSafe for OwnedDataChunk
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
The archived counterpart of this type. Unlike
Archive
, it may be unsized. Read more§type MetadataResolver = ()
type MetadataResolver = ()
The resolver for the metadata of this type. Read more
source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
Creates the archived version of the metadata for this value at the given position and writes
it to the given output. Read more
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
Mutably borrows from an owned value. Read more
source§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.