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.

Source

pub fn now(&self) -> DateTime<Local>

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 new_event( &self, draft: EventDraft, ) -> Result<impl Event + 'static, Box<dyn Error>>

Add a new event from the given draft.

Source

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

Upsert an event into the calendar.

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.

Source

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

Get a event by its id.

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.

Source

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

Counts the number of events matching the given conditions.

Source

pub fn default_todo_draft(&self) -> TodoDraft

Create a default todo draft based on the AIM configuration.

Source

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

Add a new todo from the given draft.

Source

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

Upsert an event into the calendar.

Source

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

Get a todo by its id.

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.

Source

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

Counts the number of todos matching the given conditions.

Source

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

Flush the short IDs to remove all entries.

Source

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

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

Trait Implementations§

Source§

impl Clone for Aim

Source§

fn clone(&self) -> Aim

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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 Freeze for Aim

§

impl !RefUnwindSafe for Aim

§

impl Send for Aim

§

impl Sync for Aim

§

impl Unpin for Aim

§

impl !UnwindSafe 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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
Source§

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