Skip to main content

InMemoryAddressBookStore

Struct InMemoryAddressBookStore 

Source
pub struct InMemoryAddressBookStore { /* private fields */ }
Expand description

In-memory AddressBookStore backed by Vecs under an RwLock. Build via Self::new + chainable with_* setters.

Implementations§

Source§

impl InMemoryAddressBookStore

Source

pub fn new() -> Self

Construct an empty store.

Source

pub fn with_book(self, owner: &str, book: AddressBook) -> Self

Append an address book owned by owner. Use make_book for a sane default shape.

Source

pub fn with_contact(self, book_id: i64, contact: Contact) -> Self

Append a contact to the given book id.

Source

pub fn list_books_fails(self, msg: &str) -> Self

Make AddressBookStore::list_address_books return an error carrying msg.

Source

pub fn get_book_fails(self, msg: &str) -> Self

Make AddressBookStore::get_address_book return an error carrying msg.

Source

pub fn list_contacts_fails(self, msg: &str) -> Self

Make AddressBookStore::list_contacts return an error carrying msg.

Source

pub fn get_contact_fails(self, msg: &str) -> Self

Make AddressBookStore::get_contact return an error carrying msg.

Source

pub fn contact_etag_fails(self, msg: &str) -> Self

Make AddressBookStore::contact_etag return an error carrying msg.

Source

pub fn put_contact_fails(self, msg: &str) -> Self

Make AddressBookStore::put_contact return an error carrying msg.

Source

pub fn delete_contact_fails(self, msg: &str) -> Self

Make AddressBookStore::delete_contact return an error carrying msg.

Source

pub fn ensure_default_fails(self, msg: &str) -> Self

Make the ensure_default_* trait method return an error carrying msg.

Source

pub fn contacts_in(&self, book_id: i64) -> Vec<Contact>

Read back every contact currently stored for book_id.

Trait Implementations§

Source§

impl AddressBookStore for InMemoryAddressBookStore

Source§

fn list_address_books<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<AddressBook>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List every address book owned by user.
Source§

fn get_address_book<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, book_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<AddressBook>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Look up an address book by user + URL-decoded book_name.
Source§

fn list_contacts<'life0, 'async_trait>( &'life0 self, book_id: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<Contact>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List every contact in book_id.
Source§

fn get_contact<'life0, 'life1, 'async_trait>( &'life0 self, book_id: i64, uid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Contact>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Look up a single contact by (book_id, uid).
Source§

fn contact_etag<'life0, 'life1, 'async_trait>( &'life0 self, book_id: i64, uid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch only the etag for (book_id, uid). Used for precondition checks.
Source§

fn put_contact<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, book_id: i64, uid: &'life1 str, vcard: &'life2 str, etag: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<PutResult, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Insert or update a contact.
Source§

fn delete_contact<'life0, 'life1, 'async_trait>( &'life0 self, book_id: i64, uid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a contact. Returns true on delete, false on not-found.
Source§

fn ensure_default_address_book<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a “Default” address book for user if they have none.
Source§

impl Default for InMemoryAddressBookStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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