Trait precis_core::profile::Profile

source ·
pub trait Profile {
    // Required methods
    fn prepare<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error>
       where S: Into<Cow<'a, str>>;
    fn enforce<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error>
       where S: Into<Cow<'a, str>>;
    fn compare<A, B>(&self, s1: A, s2: B) -> Result<bool, Error>
       where A: AsRef<str>,
             B: AsRef<str>;
}
Expand description

Profile enables application protocols to apply the string classes in ways that are appropriate for common constructs.

Required Methods§

source

fn prepare<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error>
where S: Into<Cow<'a, str>>,

Ensures that the code points in a single input string are allowed by the underlying PRECIS string class, and sometimes also entails applying one or more of the rules specified for a particular string class or profile thereof.

§Arguments:
  • s: String value
§Returns

The same string if no modification were required or a new allocated string if s needed further modifications as a result of applying the rules defined by this profile to prepare the string

source

fn enforce<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error>
where S: Into<Cow<'a, str>>,

Applies all the rules specified for a particular string class, or profile thereof, to a single input string, for the purpose of checking whether the string conforms to all the rules and thus determining if the string can be used in a given protocol slot.

§Arguments:
  • s: String value
§Returns

The same string if no modification were required or a new allocated string if s needed further modifications as a result of enforcing the string according to the rules defined by this profile.

source

fn compare<A, B>(&self, s1: A, s2: B) -> Result<bool, Error>
where A: AsRef<str>, B: AsRef<str>,

Comparison entails applying all the rules specified for a particular string class, or profile thereof, to two separate input strings, for the purpose of determining if the two strings are equivalent.

Object Safety§

This trait is not object safe.

Implementors§