Client

Struct Client 

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

A CalDAV data source that fetches its data from a CalDAV server

Implementations§

Source§

impl Client

Source

pub fn new<S: AsRef<str>, T: ToString, U: ToString>( url: S, username: T, password: U, ) -> Result<Self, Box<dyn Error>>

Create a client. This does not start a connection

Examples found in repository?
examples/shared.rs (line 26)
23pub async fn initial_sync(cache_folder: &str) -> CalDavProvider {
24    let cache_path = Path::new(cache_folder);
25
26    let client = Client::new(URL, USERNAME, PASSWORD).unwrap();
27    let cache = match Cache::from_folder(&cache_path) {
28        Ok(cache) => cache,
29        Err(err) => {
30            log::warn!("Invalid cache file: {}. Using a default cache", err);
31            Cache::new(&cache_path)
32        }
33    };
34    let mut provider = CalDavProvider::new(client, cache);
35
36
37    let cals = provider.local().get_calendars().await.unwrap();
38    println!("---- Local items, before sync -----");
39    kitchen_fridge::utils::print_calendar_list(&cals).await;
40
41    println!("Starting a sync...");
42    println!("Depending on your RUST_LOG value, you may see more or less details about the progress.");
43    // Note that we could use sync_with_feedback() to have better and formatted feedback
44    if provider.sync().await == false {
45        log::warn!("Sync did not complete, see the previous log lines for more info. You can safely start a new sync.");
46    }
47    provider.local().save_to_folder().unwrap();
48
49    println!("---- Local items, after sync -----");
50    let cals = provider.local().get_calendars().await.unwrap();
51    kitchen_fridge::utils::print_calendar_list(&cals).await;
52
53    provider
54}

Trait Implementations§

Source§

impl CalDavSource<RemoteCalendar> for Client

Source§

fn get_calendars<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<Url, Arc<Mutex<RemoteCalendar>>>, Box<dyn Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the current calendars that this source contains This function may trigger an update (that can be a long process, or that can even fail, e.g. in case of a remote server)
Source§

fn get_calendar<'life0, 'life1, 'async_trait>( &'life0 self, url: &'life1 Url, ) -> Pin<Box<dyn Future<Output = Option<Arc<Mutex<RemoteCalendar>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the calendar matching the URL
Source§

fn create_calendar<'life0, 'async_trait>( &'life0 mut self, url: Url, name: String, supported_components: SupportedComponents, color: Option<Color>, ) -> Pin<Box<dyn Future<Output = Result<Arc<Mutex<RemoteCalendar>>, Box<dyn Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a calendar if it did not exist, and return it
Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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