Struct spinoso_regexp::Utf8

source ·
pub struct Utf8 { /* private fields */ }

Implementations§

source§

impl Utf8

source

pub fn with_literal_derived_encoding( source: Source, config: Config, encoding: Encoding, ) -> Result<Self, Error>

Construct a Regexp with a UTF-8 regex backend.

The constructed regexp is Unicode aware. All character classes used in patterns other than POSIX character classes support all of Unicode.

Utf8 regexps require their patterns and haystacks to be valid UTF-8.

§Examples
let pattern = br"[[:alpha:]]\d+ \d+";
let source = Source::with_pattern_and_options(pattern.to_vec(), Options::default());
let config = Config::from(&source);
let regexp = Utf8::with_literal_derived_encoding(source, config, Encoding::None)?;
assert!(regexp.is_match("a123 १०೩೬".as_bytes(), None)?);
§Errors

If the pattern in the given source is not valid UTF-8, an ArgumentError is returned. If the given source pattern fails to parse, either a SyntaxError or RegexpError is returned depending on the source Options.

source

pub fn captures<'a>( &self, haystack: &'a [u8], ) -> Result<Option<Captures<'a>>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn capture_indices_for_name<'a, 'b>( &'a self, name: &'b [u8], ) -> CaptureIndices<'a, 'b>

source

pub fn captures_len(&self) -> usize

Returns the number of captures.

source

pub fn capture_count_for_haystack( &self, haystack: &[u8], ) -> Result<usize, ArgumentError>

The number of captures for a match of haystack against this regexp.

Captures represents a group of captured strings for a single match.

If there is a match, the returned value is always greater than 0; the 0th capture always corresponds to the entire match.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn entire_match<'a>( &self, haystack: &'a [u8], ) -> Result<Option<&'a [u8]>, Error>

Return the 0th capture group if haystack is matched by this regexp.

The 0th capture always corresponds to the entire match.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn named_captures(&self) -> NamedCaptures

Returns a hash representing information about the named captures of this Regexp.

A key of the hash is a name of the named captures. A value of the hash is an array which is list of indexes of corresponding named captures.

source

pub fn named_captures_for_haystack( &self, haystack: &[u8], ) -> Result<Option<NamedCapturesForHaystack>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn names(&self) -> Vec<Vec<u8>>

source

pub fn pos( &self, haystack: &[u8], at: usize, ) -> Result<Option<(usize, usize)>, Error>

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn is_match(&self, haystack: &[u8], pos: Option<i64>) -> Result<bool, Error>

Check whether this regexp matches the given haystack starting at an offset.

If the given offset is negative, it counts backward from the end of the haystack.

§Errors

If the given haystack is not valid UTF-8, an error is returned.

source

pub fn debug(&self) -> Debug<'_>

source

pub fn is_literal(&self) -> bool

source

pub fn source(&self) -> &Source

source

pub fn config(&self) -> &Config

source

pub fn encoding(&self) -> Encoding

source

pub fn string(&self) -> &[u8]

Trait Implementations§

source§

impl Clone for Utf8

source§

fn clone(&self) -> Utf8

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 Debug for Utf8

source§

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

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

impl Display for Utf8

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Utf8

§

impl RefUnwindSafe for Utf8

§

impl Send for Utf8

§

impl Sync for Utf8

§

impl Unpin for Utf8

§

impl UnwindSafe for Utf8

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> 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> ToString for T
where T: Display + ?Sized,

source§

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

§

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.