pub struct Client { /* private fields */ }Expand description
A CalDAV data source that fetches its data from a CalDAV server
Implementations§
Source§impl Client
impl Client
Sourcepub fn new<S: AsRef<str>, T: ToString, U: ToString>(
url: S,
username: T,
password: U,
) -> Result<Self, Box<dyn Error>>
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
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,
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,
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,
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
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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