pub struct TextCleaner { /* private fields */ }Expand description
Main cleaner.
Implementations§
Source§impl TextCleaner
impl TextCleaner
Sourcepub fn new(options: CleaningOptions) -> Self
pub fn new(options: CleaningOptions) -> Self
Create a cleaner from explicit options.
§Arguments
options: Cleaning behavior configuration.
§Returns
A reusable TextCleaner.
Sourcepub fn options(&self) -> &CleaningOptions
pub fn options(&self) -> &CleaningOptions
Sourcepub fn clean<'a>(&self, text: &'a str) -> CleaningResult<'a>
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.
Sourcepub fn clean_into<'output>(
&self,
text: &str,
out: &'output mut String,
) -> CleaningResult<'output>
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.
Sourcepub fn try_clean<'a>(
&self,
text: &'a str,
) -> Result<CleaningResult<'a>, CleaningError>
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.
Sourcepub fn try_clean_into<'output>(
&self,
text: &str,
out: &'output mut String,
) -> Result<CleaningResult<'output>, CleaningError>
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.
Sourcepub fn try_clean_with_context<'a>(
&self,
text: &'a str,
has_prior_output: bool,
) -> Result<CleaningResult<'a>, CleaningError>
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.
Sourcepub fn try_clean_into_with_context<'output>(
&self,
text: &str,
out: &'output mut String,
has_prior_output: bool,
) -> Result<CleaningResult<'output>, CleaningError>
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.