pub struct FileMetadata {
pub filename: String,
pub checksum: [u8; 32],
pub compressed: bool,
}Expand description
File metadata stored with encrypted data
Fields§
§filename: StringOriginal filename with extension
checksum: [u8; 32]File checksum (SHA-256)
compressed: boolWhether the data was compressed
Implementations§
Source§impl FileMetadata
impl FileMetadata
Sourcepub fn new(filename: String, checksum: [u8; 32], compressed: bool) -> Self
pub fn new(filename: String, checksum: [u8; 32], compressed: bool) -> Self
Create new file metadata
Sourcepub fn from_file(file_path: &Path, data: &[u8], compressed: bool) -> Self
pub fn from_file(file_path: &Path, data: &[u8], compressed: bool) -> Self
Create metadata from file path and data
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), CryptoError>
pub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), CryptoError>
Deserialize metadata from bytes
Sourcepub fn verify_checksum(&self, data: &[u8]) -> bool
pub fn verify_checksum(&self, data: &[u8]) -> bool
Verify checksum against data
Trait Implementations§
Source§impl Clone for FileMetadata
impl Clone for FileMetadata
Source§fn clone(&self) -> FileMetadata
fn clone(&self) -> FileMetadata
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for FileMetadata
impl RefUnwindSafe for FileMetadata
impl Send for FileMetadata
impl Sync for FileMetadata
impl Unpin for FileMetadata
impl UnwindSafe for FileMetadata
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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