Struct Collection

Source
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>

Source

pub async fn items(&self) -> Result<Vec<Item<'a>>, Error>

Retrieve the list of available Item in the collection.

Source

pub async fn label(&self) -> Result<String, Error>

The collection label.

Source

pub async fn set_label(&self, label: &str) -> Result<(), Error>

Set the collection label.

Source

pub async fn is_locked(&self) -> Result<bool, Error>

Get whether the collection is locked.

Source

pub async fn created(&self) -> Result<Duration, Error>

The UNIX time when the collection was created.

Source

pub async fn modified(&self) -> Result<Duration, Error>

The UNIX time when the collection was modified.

Source

pub async fn search_items( &self, attributes: &impl AsAttributes, ) -> Result<Vec<Item<'a>>, Error>

Search for items based on their attributes.

Source

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 the attributes matches an existing secret.
Source

pub async fn unlock( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>

Unlock the collection.

Source

pub async fn lock( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>

Lock the collection.

Source

pub async fn delete( &self, window_id: Option<WindowIdentifier>, ) -> Result<(), Error>

Delete the collection.

Source

pub fn path(&self) -> &ObjectPath<'_>

Returns collection path

Source

pub async fn receive_item_created( &self, ) -> Result<impl Stream<Item = Item<'a>> + '_, Error>

Stream yielding when new items get created

Source

pub async fn receive_item_changed( &self, ) -> Result<impl Stream<Item = Item<'a>> + '_, Error>

Stream yielding when existing items get changed

Source

pub async fn receive_item_deleted( &self, ) -> Result<impl Stream<Item = OwnedObjectPath>, Error>

Stream yielding when existing items get deleted

Trait Implementations§

Source§

impl<'a> Debug for Collection<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Collection<'a>

§

impl<'a> !RefUnwindSafe for Collection<'a>

§

impl<'a> Send for Collection<'a>

§

impl<'a> Sync for Collection<'a>

§

impl<'a> Unpin for Collection<'a>

§

impl<'a> !UnwindSafe for Collection<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,