[−][src]Struct sec_store::Store
Secure storage API
Values are stored in memory encrypted, user can save storages manually
and lately restore it using serde
Key
is stored as hash, while Value
is stored as encrypted bytes.
Implementations
impl Store
[src]
pub fn new(user: &[u8], pass: &[u8]) -> Self
[src]
Creates new instance using creds.
Parameters:
user
- user specific information that can distinguish him from others.pass
- can be any number of arbitrary bytes except it MUST NOT be zero length.
pub fn from_inner(
inner: BTreeMap<u128, Vec<u8>>,
user: &[u8],
pass: &[u8]
) -> Self
[src]
inner: BTreeMap<u128, Vec<u8>>,
user: &[u8],
pass: &[u8]
) -> Self
Creates new instance using provided storage and pass.
Parameters:
storage
- already initialized storage, only can work with storage that is returned bySelf::inner
.user
- user specific information that can distinguish him from others.pass
- can be any number of arbitrary bytes except it MUST NOT be zero length.
pub fn inner(&self) -> &BTreeMap<u128, Vec<u8>>
[src]
Accesses inner representation of storage, allowing to serialize it.
pub fn into_inner(self) -> BTreeMap<u128, Vec<u8>>
[src]
Consumes self, returning underlying storage.
pub fn len(&self) -> usize
[src]
Returns number of key-value pairs
pub fn get_to(&self, key: &[u8], dest: &mut [u8]) -> Result<usize, ()>
[src]
Retrieves value for key
, storing decrypted value in dest
.
Returns Err
when key doesn't exist or user has no permission to read it.
Otherwise returns number of bytes written, or '0' in case of insufficient storage.
pub fn get_to_vec(&self, key: &[u8], dest: &mut Vec<u8>) -> Result<usize, ()>
[src]
Retrieves value for key
to store in dest
, resulting in it being overwritten.
Returns Err
when key doesn't exist or user has no permission to read it.
Otherwise returns number of bytes written.
pub fn get(&self, key: &[u8]) -> Option<Vec<u8>>
[src]
Retrieves value for key
Returns None
if decryption failed.
pub fn insert_owned(&mut self, key: &[u8], value: Vec<u8>) -> Option<Vec<u8>>
[src]
Inserts new owned value
for key
, returning previous one, if any.
pub fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>
[src]
Inserts new value
for key
, returning previous one, if any.
pub fn remove_to(&mut self, key: &[u8], dest: &mut [u8]) -> Result<usize, ()>
[src]
Extracts value under key
to specified dest
Returns Err
when key doesn't exist, or user has no permission to read it.
Otherwise returns number of bytes written, or '0' in case of insufficient storage.
Note that value is removed only if Ok(size) >= Ok(1)
pub fn remove_to_vec(
&mut self,
key: &[u8],
dest: &mut Vec<u8>
) -> Result<usize, ()>
[src]
&mut self,
key: &[u8],
dest: &mut Vec<u8>
) -> Result<usize, ()>
Extracts value under key
to specified dest
Returns Err
when key doesn't exist, or user has no permission to read it.
Otherwise returns number of bytes written.
pub fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>
[src]
Removes key
, returning previous value, if any.
Failing to decrypt, doesn't remove value.
pub fn remove_key(&mut self, key: &[u8]) -> bool
[src]
Removes key
, returning whether it was set previously.
Note that it only removes value, without checking if you can read it.
Auto Trait Implementations
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
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,
pub 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, 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.
pub 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>,