pub struct Collection<'a> { /* private fields */ }
Expand description
A collection allows to store and retrieve items.
The collection can be either in a locked or unlocked state, use
Collection::lock
or Collection::unlock
to lock or unlock it.
Using Collection::search_items
or Collection::items
will return no
items if the collection is locked.
Note
If the collection is deleted using Collection::delete
any future usage
of it API will fail with Error::Deleted
.
Implementations§
Source§impl<'a> Collection<'a>
impl<'a> Collection<'a>
Sourcepub async fn items(&self) -> Result<Vec<Item<'a>>, Error>
pub async fn items(&self) -> Result<Vec<Item<'a>>, Error>
Retrieve the list of available Item
in the collection.
Sourcepub async fn created(&self) -> Result<Duration, Error>
pub async fn created(&self) -> Result<Duration, Error>
The UNIX time when the collection was created.
Sourcepub async fn modified(&self) -> Result<Duration, Error>
pub async fn modified(&self) -> Result<Duration, Error>
The UNIX time when the collection was modified.
Sourcepub async fn search_items(
&self,
attributes: &impl AsAttributes,
) -> Result<Vec<Item<'a>>, Error>
pub async fn search_items( &self, attributes: &impl AsAttributes, ) -> Result<Vec<Item<'a>>, Error>
Search for items based on their attributes.
Sourcepub async fn create_item(
&self,
label: &str,
attributes: &impl AsAttributes,
secret: impl Into<Secret>,
replace: bool,
window_id: Option<WindowIdentifier>,
) -> Result<Item<'a>, Error>
pub async fn create_item( &self, label: &str, attributes: &impl AsAttributes, secret: impl Into<Secret>, replace: bool, window_id: Option<WindowIdentifier>, ) -> Result<Item<'a>, Error>
Create a new item on the collection
§Arguments
label
- A user visible label of the item.attributes
- A map of key/value attributes, used to find the item later.secret
- The secret to store.replace
- Whether to replace the value if theattributes
matches an existingsecret
.
Sourcepub async fn unlock(
&self,
window_id: Option<WindowIdentifier>,
) -> Result<(), Error>
pub async fn unlock( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>
Unlock the collection.
Sourcepub async fn lock(
&self,
window_id: Option<WindowIdentifier>,
) -> Result<(), Error>
pub async fn lock( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>
Lock the collection.
Sourcepub async fn delete(
&self,
window_id: Option<WindowIdentifier>,
) -> Result<(), Error>
pub async fn delete( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>
Delete the collection.
Sourcepub fn path(&self) -> &ObjectPath<'_>
pub fn path(&self) -> &ObjectPath<'_>
Returns collection path
Sourcepub async fn receive_item_created(
&self,
) -> Result<impl Stream<Item = Item<'a>> + '_, Error>
pub async fn receive_item_created( &self, ) -> Result<impl Stream<Item = Item<'a>> + '_, Error>
Stream yielding when new items get created
Sourcepub async fn receive_item_changed(
&self,
) -> Result<impl Stream<Item = Item<'a>> + '_, Error>
pub async fn receive_item_changed( &self, ) -> Result<impl Stream<Item = Item<'a>> + '_, Error>
Stream yielding when existing items get changed
Sourcepub async fn receive_item_deleted(
&self,
) -> Result<impl Stream<Item = OwnedObjectPath>, Error>
pub async fn receive_item_deleted( &self, ) -> Result<impl Stream<Item = OwnedObjectPath>, Error>
Stream yielding when existing items get deleted