Struct sanitizer::StringSanitizer[][src]

pub struct StringSanitizer(_);

The Sanitizer structure is a wrapper over a String type which is to be sanitized.

Example

use sanitizer::prelude::*;

let mut instance = StringSanitizer::from(" HELLO ");
instance
	.trim()
	.to_lowercase();
assert_eq!(instance.get(), "hello");

Implementations

impl StringSanitizer[src]

pub fn new(content: String) -> Self[src]

Create a new instance of the struct with the content as the string specified in the argument

pub fn get(self) -> String[src]

Consume the struct and return the underlying string

pub fn trim(&mut self) -> &mut Self[src]

Trim the string

pub fn numeric(&mut self) -> &mut Self[src]

Remove non numeric characters from the string

pub fn alphanumeric(&mut self) -> &mut Self[src]

Remove non alphanumeric characters from the string

pub fn to_lowercase(&mut self) -> &mut Self[src]

Convert string to lower case

pub fn to_uppercase(&mut self) -> &mut Self[src]

Convert string to upper case

pub fn to_camel_case(&mut self) -> &mut Self[src]

Convert string to camel case

pub fn to_snake_case(&mut self) -> &mut Self[src]

Convert string to snake case

pub fn to_screaming_snakecase(&mut self) -> &mut Self[src]

Convert string to screaming snake case

pub fn clamp_max(&mut self, limit: usize) -> &mut Self[src]

Set the maximum lenght of the content

pub fn e164(&mut self) -> &mut Self[src]

Convert the phone number to the E164 International Standard

pub fn cut(&mut self, amount: usize) -> &mut Self[src]

Truncate the string with the given amount

pub fn call<F>(&mut self, func: F) -> &mut Self where
    F: FnOnce(&str) -> String
[src]

Call a custom function for sanitizing the string

Trait Implementations

impl From<&'_ str> for StringSanitizer[src]

impl From<String> for StringSanitizer[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.