Trait precis_core::profile::PrecisFastInvocation
source · pub trait PrecisFastInvocation {
// Required methods
fn prepare<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
where S: Into<Cow<'a, str>>;
fn enforce<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
where S: Into<Cow<'a, str>>;
fn compare<A, B>(s1: A, s2: B) -> Result<bool, Error>
where A: AsRef<str>,
B: AsRef<str>;
}
Expand description
Fast invocation trait that allows profiles to be used without providing
a specific instance. This is usually achieved by using a static instance
allocated with lazy_static
Required Methods§
sourcefn prepare<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
fn prepare<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
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
sourcefn enforce<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
fn enforce<'a, S>(s: S) -> Result<Cow<'a, str>, Error>
Applies all 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.