Struct secret::SecretItem
[−]
[src]
pub struct SecretItem(_);
SecretItem represents a secret item stored in the Secret Service.
Each item has a value, represented by a SecretValue, which can be retrieved
by get_secret()
or set by set_secret()
. The item is only available when
the item is not locked.
Items can be locked or unlocked using the Lock::lock()
or Lock::unlock()
functions. The Lock trait is implemented by SecretItem. The Secret Service
may not be able to unlock individual items, and may unlock an entire
collection when a single item is unlocked.
Each item has a set of attributes, which are used to locate the item later.
These are not stored or transferred in a secure manner. Each attribute has
a string name and a string value. Use SecretService::search()
to search
for items based on their attributes, and set_attributes()
to change the
attributes associated with an item.
Items can be created with create()
or SecretService::store()
.
Methods
impl SecretItem
fn create(collection: &SecretCollection, attributes: &HashMap<String, String>, label: &str, value: &SecretValue) -> SecretResult<SecretItem>
Create a new item in the secret service. collection: a secret collection to create this item in attributes: attributes for the new item. label: label for the new item value: secret value for the new item
fn delete(&self) -> SecretResult<()>
Delete this secret item.
fn get_schema_name(&self) -> String
Get the name of the attribute schema.
fn get_created(&self) -> u64
Get the created date and time of the item. The return value is the number of seconds since the unix epoch, January 1st 1970.
fn get_modified(&self) -> u64
Get the modified date and time of the item. The return value is the number of seconds since the unix epoch, January 1st 1970.
fn get_label(&self) -> String
Get the label of the item.
fn get_service(&self) -> SecretService
Get the SecretService this item was created with.
fn load_secret(&self) -> SecretResult<()>
Ensure that the SecretValue of this item is loaded.
fn get_secret(&self) -> Option<SecretValue>
Get the SecretValue of this item. The item must be unlocked and the value must be loaded.
fn set_secret(&self, value: &SecretValue) -> SecretResult<()>
Set the secret value of this item. Each item has a single secret which might be a password or some other secret binary value (not supported yet).
fn get_attributes(&self) -> HashMap<String, String>
Get the attributes of this item.
fn set_attributes(&self, attributes: &HashMap<String, String>) -> SecretResult<()>
Set the attributes of this item.
fn is_locked(&self) -> bool
Check if the item is currently locked.