Struct sanitizer::StringSanitizer [−][src]
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]
F: FnOnce(&str) -> String,
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
impl RefUnwindSafe for StringSanitizer
impl Send for StringSanitizer
impl Sync for StringSanitizer
impl Unpin for StringSanitizer
impl UnwindSafe for StringSanitizer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,