icalendar

Struct Alarm

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

VALARM (RFC 5545, Section 3.6.6 )

Alarms can be added to Events and Todos. An alarm always has a Trigger and an Action. The Trigger describes when the alarm should happen and the Action describes what should happen.

§Triggers

An alarm can either be triggered at an absolute time or in relation to its event, so the Trigger can either be an absolute CalendarDateTime or a Duration plus a relation tag, which defines wether the duration is related to the events start or end.

§Action

When it is time for the Alarm to occur we have to define what is actually supposed to happen. The RFC5545 know three different actions, two of which are currently implemented.

  1. Display
  2. Audio
  3. Email (not yet implemented)

 // alarm will occur one minute from now
 let event_with_absolute_audio_alarm = Event::new()
     .alarm(
         Alarm::audio(Utc::now() + Duration::minutes(1))
         .duration_and_repeat(Duration::minutes(1), 4)
     )
     .done();

 // alarm will occur one minute before the start
 let event_with_relative_display_alarm = Event::new()
     .alarm(
         Alarm::display("ALARM! ALARM!", -Duration::minutes(1))
         .duration_and_repeat(Duration::minutes(1), 4)
     )
     .done();

 // alarm will occur one minute before the end
 let event_with_relative_display_alarm_end = Event::new()
     .alarm(
         Alarm::display("ALARM! ALARM!", (-Duration::minutes(1), Related::End))
         .duration_and_repeat(Duration::minutes(1), 4)
     )
     .done();

Implementations§

Source§

impl Alarm

Source

pub fn audio<T: Into<Trigger>>(trigger: T) -> Self

Creates a new Audio- Alarm Component

§Definition

‘action’ and ‘trigger’ are both REQUIRED, but MUST NOT occur more than once.

action / trigger /

‘duration’ and ‘repeat’ are both OPTIONAL, and MUST NOT occur more than once each; but if one occurs, so MUST the other.

duration / repeat /

The following is OPTIONAL, but MUST NOT occur more than once.

attach /

The following is OPTIONAL, and MAY occur more than once.

x-prop / iana-prop

Source

pub fn display(description: &str, trigger: impl Into<Trigger>) -> Self

Creates a new Display- Alarm Component

§Definition

The following are REQUIRED, but MUST NOT occur more than once.

action / description / trigger /

‘duration’ and ‘repeat’ are both OPTIONAL, and MUST NOT occur more than once each; but if one occurs, so MUST the other.

duration / repeat /

The following is OPTIONAL, and MAY occur more than once.

x-prop / iana-prop

Source

pub fn duration_and_repeat<R: Copy + Clone + Into<Repeat>>( self, duration: Duration, repeat_count: R, ) -> Self

Sets duration the REPEAT and DURATION property, which must not occur independent from one another

Source

pub fn done(&mut self) -> Self

End of builder pattern. copies over everything

Trait Implementations§

Source§

impl Clone for Alarm

Source§

fn clone(&self) -> Alarm

Returns a copy 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 Component for Alarm

Source§

fn component_kind(&self) -> String

Tells you what kind of Component this is

Might be VEVENT, VTODO, VALARM etc

Source§

fn properties(&self) -> &BTreeMap<String, Property>

Read-only access to properties

Source§

fn components(&self) -> &[Other]

Read-only access to properties

Source§

fn multi_properties(&self) -> &BTreeMap<String, Vec<Property>>

Read-only access to multi_properties

Source§

fn append_property(&mut self, property: impl Into<Property>) -> &mut Self

Adds a Property

Source§

fn append_multi_property(&mut self, property: impl Into<Property>) -> &mut Self

Adds a Property of which there may be many

Source§

fn append_component(&mut self, child: impl Into<Other>) -> &mut Self

Append a given Component
Source§

fn property_value(&self, key: &str) -> Option<&str>

Gets the value of a property.
Source§

fn fmt_write<W: Write>(&self, out: &mut W) -> Result<(), Error>

Writes Component using std::fmt.
Source§

fn to_string(&self) -> String

Serializes this component into rfc5545 again Read more
Source§

fn try_into_string(&self) -> Result<String, Error>

Serializes this component into rfc5545 again
Source§

fn add_property( &mut self, key: impl Into<String>, val: impl Into<String>, ) -> &mut Self

Construct and append a Property
Source§

fn add_property_pre_alloc(&mut self, key: String, val: String) -> &mut Self

👎Deprecated
Construct and append a Property
Source§

fn add_multi_property(&mut self, key: &str, val: &str) -> &mut Self

Construct and append a Property
Source§

fn timestamp(&mut self, dt: DateTime<Utc>) -> &mut Self

Source§

fn get_timestamp(&self) -> Option<DateTime<Utc>>

Gets the DTSTAMP property.
Source§

fn get_start(&self) -> Option<DatePerhapsTime>

Gets the DTSTART Property
Source§

fn get_end(&self) -> Option<DatePerhapsTime>

Gets the DTEND Property
Source§

fn priority(&mut self, priority: u32) -> &mut Self

Defines the relative priority. Read more
Source§

fn get_priority(&self) -> Option<u32>

Gets the relative priority. Read more
Source§

fn print(&self) -> Result<(), Error>

Prints to stdout
Source§

fn summary(&mut self, desc: &str) -> &mut Self

Set the summary
Source§

fn get_summary(&self) -> Option<&str>

Gets the summary
Source§

fn description(&mut self, desc: &str) -> &mut Self

Set the description
Source§

fn get_description(&self) -> Option<&str>

Gets the description
Source§

fn uid(&mut self, uid: &str) -> &mut Self

Set the UID
Source§

fn get_uid(&self) -> Option<&str>

Gets the UID
Source§

fn sequence(&mut self, sequence: u32) -> &mut Self

Set the sequence
Source§

fn get_sequence(&self) -> Option<u32>

Gets the SEQUENCE
Source§

fn class(&mut self, class: Class) -> &mut Self

Set the visibility class
Source§

fn get_class(&self) -> Option<Class>

Gets the visibility class
Source§

fn url(&mut self, url: &str) -> &mut Self

Sets the URL.
Source§

fn get_url(&self) -> Option<&str>

Gets the URL.
Source§

fn last_modified(&mut self, dt: DateTime<Utc>) -> &mut Self

Source§

fn get_last_modified(&self) -> Option<DateTime<Utc>>

Gets the LAST_MODIFIED property.
Source§

fn created(&mut self, dt: DateTime<Utc>) -> &mut Self

Source§

fn get_created(&self) -> Option<DateTime<Utc>>

Gets the CREATED property.
Source§

impl Debug for Alarm

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Alarm

Source§

fn eq(&self, other: &Alarm) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryInto<String> for Alarm

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<String, Self::Error>

Performs the conversion.
Source§

impl Eq for Alarm

Source§

impl StructuralPartialEq for Alarm

Auto Trait Implementations§

§

impl Freeze for Alarm

§

impl RefUnwindSafe for Alarm

§

impl Send for Alarm

§

impl Sync for Alarm

§

impl Unpin for Alarm

§

impl UnwindSafe for Alarm

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, dst: *mut u8)

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