[−][src]Struct self_encryption::SelfEncryptor
This is the encryption object and all file handling should be done using this object as the low level mechanism to read and write content. This library has no knowledge of file metadata.
Implementations
impl<S> SelfEncryptor<S> where
S: Storage + Send + Sync + 'static,
[src]
S: Storage + Send + Sync + 'static,
pub fn new(
storage: S,
data_map: DataMap
) -> Result<SelfEncryptor<S>, SelfEncryptionError<S::Error>>
[src]
storage: S,
data_map: DataMap
) -> Result<SelfEncryptor<S>, SelfEncryptionError<S::Error>>
This is the only constructor for an encryptor object. Each SelfEncryptor
is used for a
single file. The parameters are a Storage
object and a DataMap
. For a file which has
not previously been self-encrypted, use DataMap::None
.
pub async fn write<'_, '_>(
&'_ self,
data: &'_ [u8],
position: u64
) -> Result<(), SelfEncryptionError<S::Error>>
[src]
&'_ self,
data: &'_ [u8],
position: u64
) -> Result<(), SelfEncryptionError<S::Error>>
Write method mirrors a POSIX type write mechanism. It loosely mimics a filesystem interface
for easy connection to FUSE-like programs as well as fine grained access to system level
libraries for developers. The input data
will be written from the specified position
(starts from 0).
pub async fn read<'_>(
&'_ self,
position: u64,
length: u64
) -> Result<Vec<u8>, SelfEncryptionError<S::Error>>
[src]
&'_ self,
position: u64,
length: u64
) -> Result<Vec<u8>, SelfEncryptionError<S::Error>>
The returned content is read from the specified position
with specified length
. Trying
to read beyond the file size will cause the encryptor to return content filled with 0u8
s
in the gap (file size isn't affected). Any other unwritten gaps will also be filled with
'0u8's.
pub async fn close(self) -> Result<(DataMap, S), SelfEncryptionError<S::Error>>
[src]
This function returns a DataMap
, which is the info required to recover encrypted content
from data storage location. Content temporarily held in the encryptor will only get flushed
into storage when this function gets called.
pub async fn truncate<'_>(
&'_ self,
new_size: u64
) -> Result<(), SelfEncryptionError<S::Error>>
[src]
&'_ self,
new_size: u64
) -> Result<(), SelfEncryptionError<S::Error>>
Truncate the self_encryptor to the specified size (if extended, filled with 0u8
s).
pub async fn len<'_>(&'_ self) -> u64
[src]
Current file size as is known by encryptor.
pub async fn is_empty<'_>(&'_ self) -> bool
[src]
Returns true if file size as is known by encryptor == 0.
pub async fn into_storage(self) -> S
[src]
Consume this encryptor and return its storage.
Trait Implementations
Auto Trait Implementations
impl<S> !RefUnwindSafe for SelfEncryptor<S>
impl<S> Send for SelfEncryptor<S>
impl<S> Sync for SelfEncryptor<S>
impl<S> Unpin for SelfEncryptor<S>
impl<S> !UnwindSafe for SelfEncryptor<S>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,