Struct icalendar::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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryInto<String> for Alarm

§

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

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

§

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

§

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

§

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.