pub enum Alert {
    V1dot0(Alert),
    V1dot1(Alert),
    V1dot2(Alert),
}
Expand description

A CAP alert message.

Variants

V1dot0(Alert)

A CAP v1.0 alert message

V1dot1(Alert)

A CAP v1.1 alert message

V1dot2(Alert)

A CAP v1.2 alert message

Implementations

A unique identifier for this alert, assigned by the sender

A globally-unique identifier for the sender

The date and time at which this alert originated

Returns the XML namespace corresponding to the encapsulated CAP alert version.

Return this alert as the latest supported alert version, upgrading it as necessary.

CAP v1.2 is mostly a superset of earlier versions, with two exceptions:

  1. CAP <= v1.1 Resource has an optional mime_type, whereas it’s required for CAP v1.2. This crate supplies application/octet-stream as a default if needed.
// let input: &str = /* CAP v1.0 appendix A.1 */;
let alert: oasiscap::Alert = input.parse().unwrap();
match &alert {
    oasiscap::Alert::V1dot0(alert) => {
        assert!(alert.info[0].resources[0].mime_type.is_none());
    }
    _ => unreachable!(),
}

let alert = alert.into_latest();
assert_eq!(alert.info[0].resources[0].mime_type, "application/octet-stream");
  1. CAP v1.0 has Certainty::VeryLikely, while later versions do not. The specification recommends substituting Certainty::Likely, so this crate does.
// let input: &str = /* CAP v1.0 appendix A.3 */;
let alert: oasiscap::Alert = input.parse().unwrap();
match &alert {
    oasiscap::Alert::V1dot0(alert) => {
        assert_eq!(alert.info[0].certainty, oasiscap::v1dot0::Certainty::VeryLikely);
    }
    _ => unreachable!(),
}

let alert = alert.into_latest();
assert_eq!(alert.info[0].certainty, oasiscap::v1dot2::Certainty::Likely);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.