Skip to main content

InMemoryCalendarStore

Struct InMemoryCalendarStore 

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

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

Implementations§

Source§

impl InMemoryCalendarStore

Source

pub fn new() -> Self

Construct an empty store.

Source

pub fn with_calendar(self, owner: &str, cal: Calendar) -> Self

Append a calendar owned by owner. Use make_calendar for a sane default shape.

Source

pub fn with_event(self, calendar_id: i64, event: Event) -> Self

Append an event to the given calendar id.

Source

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

Make CalendarStore::list_calendars return an error carrying msg.

Source

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

Make CalendarStore::get_calendar return an error carrying msg.

Source

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

Make CalendarStore::list_events return an error carrying msg.

Source

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

Make CalendarStore::get_event return an error carrying msg.

Source

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

Make CalendarStore::event_etag return an error carrying msg.

Source

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

Make CalendarStore::put_event return an error carrying msg.

Source

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

Make CalendarStore::delete_event 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 events_in(&self, calendar_id: i64) -> Vec<Event>

Read back every event currently stored for calendar_id. Tests use this to assert handler-driven mutations.

Source

pub fn default_calendar_was_created_for(&self, user: &str) -> bool

true when CalendarStore::ensure_default_calendar fired for user.

Trait Implementations§

Source§

impl CalendarStore for InMemoryCalendarStore

Source§

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

List every calendar owned by user.
Source§

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

Look up a calendar by user + URL-decoded calendar_name. Returns Ok(None) when the calendar exists but doesn’t belong to user, or when no such calendar exists.
Source§

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

List every event in calendar_id. Order is store-defined; handlers do not rely on ordering.
Source§

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

Look up a single event by (calendar_id, uid).
Source§

fn event_etag<'life0, 'life1, 'async_trait>( &'life0 self, calendar_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 (calendar_id, uid). Used by handlers to perform If-Match / If-None-Match: * precondition checks without pulling the full icalendar body.
Source§

fn put_event<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, calendar_id: i64, uid: &'life1 str, icalendar: &'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 an event. icalendar is the raw RFC 5545 text; etag is a freshly-computed digest the handler wants the store to record. Read more
Source§

fn delete_event<'life0, 'life1, 'async_trait>( &'life0 self, calendar_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 an event. Returns true when a row was actually removed, false for not-found (handler maps that to 404).
Source§

fn ensure_default_calendar<'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,

Idempotent: create a “Default” calendar for user if they have none. Called from PROPFIND on the principal / calendar home so first-login clients see something to subscribe to.
Source§

impl Default for InMemoryCalendarStore

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.