Struct oo7::dbus::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 AsRef<[u8]>, replace: bool, content_type: &str ) -> 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.
  • content_type - The content type of the secret, usually something like text/plain.
source

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

Unlock the collection.

source

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

Lock the collection.

source

pub async fn delete(&self) -> 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

§

type Output = T

Should always be Self
source§

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

§

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

§

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