Skip to main content

ContractViolation

Enum ContractViolation 

Source
#[non_exhaustive]
pub enum ContractViolation { MissingMessage { message: String, }, MissingValue { message: String, }, MissingAttribute { message: String, attribute: String, }, UnknownVariable { message: String, attribute: Option<String>, variable: String, }, ElementMismatch { message: String, expected: Vec<String>, found: Vec<String>, }, BoolSelectorMismatch { message: String, attribute: Option<String>, variable: String, found: Vec<String>, }, BoolReferenceOutsideSelector { message: String, attribute: Option<String>, variable: String, }, UnknownTerm { term: String, referenced_from: String, }, }
Expand description

One way an external .ftl failed to satisfy a MessageContract.

Carried by L10nError::Validation. Each variant describes a mistake that would otherwise surface later as a panic or formatting error in a generated accessor.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MissingMessage

A contract message is missing from the .ftl entirely.

Fields

§message: String

The message id.

§

MissingValue

The message exists but has no value of its own, and the contract expects one (the message defines only attributes).

Fields

§message: String

The message id.

§

MissingAttribute

The message exists but lacks a required attribute.

Fields

§message: String

The message id.

§attribute: String

The missing attribute.

§

UnknownVariable

The pattern references a variable that is not a contract argument. The generated accessor would leave it unfilled, which fails to format.

Fields

§message: String

The message id.

§attribute: Option<String>

The attribute, for an attribute accessor.

§variable: String

The unknown $variable name.

§

ElementMismatch

The (Element) marker sequence does not match the contract, so the structured-message split would not produce the expected slots. The entries are rendered as $variable / -term.

Fields

§message: String

The message id.

§expected: Vec<String>

The contract’s marker sequence.

§found: Vec<String>

The sequence found in the .ftl.

§

BoolSelectorMismatch

A Boolean variable’s selector does not contain exactly [true] and [false] branches.

Fields

§message: String

The message id.

§attribute: Option<String>

The attribute, for an attribute accessor.

§variable: String

The Boolean variable driving the selector.

§found: Vec<String>

Variant keys found in the translation.

§

BoolReferenceOutsideSelector

A Boolean variable is referenced outside its selector, which would render its encoded true / false string directly.

Fields

§message: String

The message id.

§attribute: Option<String>

The attribute, for an attribute accessor.

§variable: String

The Boolean variable referenced directly.

§

UnknownTerm

A referenced term is not defined in the .ftl. Resolving it would fail to format at runtime.

Fields

§term: String

The referenced -term name.

§referenced_from: String

Where the reference was found: a message id, message.attribute, or another term rendered as -term.

Trait Implementations§

Source§

impl Clone for ContractViolation

Source§

fn clone(&self) -> ContractViolation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContractViolation

Source§

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

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

impl Display for ContractViolation

Source§

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

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

impl Eq for ContractViolation

Source§

impl PartialEq for ContractViolation

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ContractViolation

Auto Trait Implementations§

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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.