Skip to main content

Aim

Struct Aim 

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

AIM calendar application core.

Implementations§

Source§

impl Aim

Source

pub async fn new(config: Config) -> Result<Self, Box<dyn Error>>

Creates a new AIM instance with the given configuration.

§Errors

If initialization fails.

Source

pub fn now(&self) -> Zoned

The current time in the AIM instance.

Source

pub fn refresh_now(&mut self)

Refresh the current time to now.

Source

pub fn default_event_draft(&self) -> EventDraft

Create a default event draft based on the AIM configuration.

Source

pub async fn get_event( &self, id: &Id, ) -> Result<impl Event + 'static, Box<dyn Error>>

Get a event by its id.

§Errors

If the event is not found or database access fails.

Source

pub async fn find_latest_event_by_summary( &self, summary: &str, ) -> Result<Option<impl Event + 'static>, Box<dyn Error>>

Find the latest event matching the given summary.

§Errors

If database access fails.

Source

pub async fn new_event( &self, draft: EventDraft, ) -> Result<impl Event + 'static, Box<dyn Error>>

Add a new event from the given draft.

§Errors

If the event is not found, database or backend access fails.

Source

pub async fn update_event( &self, id: &Id, patch: EventPatch, ) -> Result<impl Event + 'static, Box<dyn Error>>

Upsert an event into the calendar.

§Errors

If the event is not found, database or backend access fails.

Source

pub async fn get_kind(&self, id: &Id) -> Result<Kind, Box<dyn Error>>

Get the kind of the given id, which can be either an event or a todo.

§Errors

If the id is not found or database access fails.

Source

pub async fn list_events( &self, conds: &EventConditions, pager: &Pager, ) -> Result<Vec<impl Event + 'static>, Box<dyn Error>>

List events matching the given conditions.

§Errors

If database access fails.

Source

pub async fn count_events( &self, conds: &EventConditions, ) -> Result<i64, Box<dyn Error>>

Counts the number of events matching the given conditions.

§Errors

If database access fails.

Source

pub fn default_todo_draft(&self) -> Result<TodoDraft, String>

Create a default todo draft based on the AIM configuration.

§Errors

If date/time resolution fails.

Source

pub async fn find_latest_todo_by_summary( &self, summary: &str, ) -> Result<Option<impl Todo + 'static>, Box<dyn Error>>

Find the latest todo matching the given summary.

§Errors

If database access fails.

Source

pub async fn new_todo( &self, draft: TodoDraft, ) -> Result<impl Todo + 'static, Box<dyn Error>>

Add a new todo from the given draft.

§Errors

If the todo is not found, database or backend access fails.

Source

pub async fn update_todo( &self, id: &Id, patch: TodoPatch, ) -> Result<impl Todo + 'static, Box<dyn Error>>

Upsert a todo into the calendar.

§Errors

If the todo is not found, database or backend access fails.

Source

pub async fn get_todo( &self, id: &Id, ) -> Result<impl Todo + 'static, Box<dyn Error>>

Get a todo by its id.

§Errors

If the todo is not found or database access fails.

Source

pub async fn list_todos( &self, conds: &TodoConditions, sort: &[TodoSort], pager: &Pager, ) -> Result<Vec<impl Todo + 'static>, Box<dyn Error>>

List todos matching the given conditions, sorted and paginated.

§Errors

If database access fails.

Source

pub async fn count_todos( &self, conds: &TodoConditions, ) -> Result<i64, Box<dyn Error>>

Counts the number of todos matching the given conditions.

§Errors

If database access fails.

Source

pub async fn list_calendars( &self, ) -> Result<Vec<CalendarRecord>, Box<dyn Error>>

List known calendars ordered by priority.

§Errors

If database access fails.

Source

pub async fn get_calendar_details( &self, id: &str, ) -> Result<CalendarDetails, Box<dyn Error>>

Get detailed information for a single calendar.

§Errors

If the calendar is not found or database access fails.

Source

pub fn startup_notices(&self) -> &[String]

Startup notices produced while reconciling config and database state.

Source

pub async fn flush_short_ids(&self) -> Result<(), Box<dyn Error>>

Flush the short IDs to remove all entries.

§Errors

If database access fails.

Source

pub async fn sync(&self) -> Result<SyncResult, Box<dyn Error>>

Synchronizes the store with the local cache.

§Errors

If synchronization fails.

Source

pub async fn close(self) -> Result<(), Box<dyn Error>>

Close the AIM instance, saving any changes to the database.

§Errors

If closing the database fails.

Trait Implementations§

Source§

impl Debug for Aim

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Aim

§

impl !UnwindSafe for Aim

§

impl Freeze for Aim

§

impl Send for Aim

§

impl Sync for Aim

§

impl Unpin for Aim

§

impl UnsafeUnpin for Aim

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> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
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<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