Skip to main content

TextCleaner

Struct TextCleaner 

Source
pub struct TextCleaner { /* private fields */ }
Expand description

Main cleaner.

Implementations§

Source§

impl TextCleaner

Source

pub fn new(options: CleaningOptions) -> Self

Create a cleaner from explicit options.

§Arguments
  • options: Cleaning behavior configuration.
§Returns

A reusable TextCleaner.

Source

pub fn options(&self) -> &CleaningOptions

Borrow the cleaner options.

§Returns

Immutable reference to configured CleaningOptions.

Source

pub fn clean<'a>(&self, text: &'a str) -> CleaningResult<'a>

Clean text and panic on unavailable normalization features.

§Arguments
  • text: Input text to normalize.
§Returns

Cleaned output and stats.

§Errors

This infallible wrapper does not return errors; use TextCleaner::try_clean for error handling.

§Panics

Panics when a normalization mode requires the unorm feature but it is not enabled.

Source

pub fn clean_into<'output>( &self, text: &str, out: &'output mut String, ) -> CleaningResult<'output>

Clean text into a caller-provided buffer and panic on unavailable normalization features.

§Arguments
  • text: Input text to normalize.
  • out: Output buffer to reuse.
§Returns

A result borrowing from out.

§Errors

This infallible wrapper does not return errors; use TextCleaner::try_clean_into for error handling.

§Panics

Panics when a normalization mode requires the unorm feature but it is not enabled.

Source

pub fn try_clean<'a>( &self, text: &'a str, ) -> Result<CleaningResult<'a>, CleaningError>

Fallible variant of TextCleaner::clean.

§Arguments
  • text: Input text to normalize.
§Returns

Cleaned output and stats.

§Errors

Returns CleaningError::NormalizationUnavailable when normalization was requested without the unorm feature.

Source

pub fn try_clean_into<'output>( &self, text: &str, out: &'output mut String, ) -> Result<CleaningResult<'output>, CleaningError>

Fallible variant of TextCleaner::clean_into.

§Arguments
  • text: Input text to normalize.
  • out: Output buffer to reuse.
§Returns

A result borrowing from out.

§Errors

Returns CleaningError::NormalizationUnavailable when normalization was requested without the unorm feature.

Source

pub fn try_clean_with_context<'a>( &self, text: &'a str, has_prior_output: bool, ) -> Result<CleaningResult<'a>, CleaningError>

Clean text while preserving context about previously emitted output.

§Arguments
  • text: Input chunk to clean.
  • has_prior_output: Whether earlier chunks already emitted output.
§Returns

Cleaned output and stats.

§Errors

Returns CleaningError::NormalizationUnavailable when normalization was requested without the unorm feature.

Source

pub fn try_clean_into_with_context<'output>( &self, text: &str, out: &'output mut String, has_prior_output: bool, ) -> Result<CleaningResult<'output>, CleaningError>

Buffer-reusing context-aware cleaner.

§Arguments
  • text: Input chunk to clean.
  • out: Output buffer to reuse.
  • has_prior_output: Whether earlier chunks already emitted output.
§Returns

A result borrowing from out.

§Errors

Returns CleaningError::NormalizationUnavailable when normalization was requested without the unorm feature.

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> 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, 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,