Trait typeid_prefix::Sanitize

source ·
pub trait Sanitize {
    // Required method
    fn sanitize_and_create(&self) -> TypeIdPrefix
       where Self: AsRef<str>;
}
Expand description

A trait for sanitizing and creating a valid TypeIdPrefix from a given input.

This trait is implemented for any type that can be converted to a string slice (AsRef<str>). It provides a method to clean and create a valid TypeIdPrefix, even from invalid input.

§Examples

use typeid_prefix::Sanitize;

let sanitized = "Invalid String 123!@#".sanitize_and_create();
assert_eq!(sanitized.as_str(), "invalidstring");

Required Methods§

source

fn sanitize_and_create(&self) -> TypeIdPrefix
where Self: AsRef<str>,

Sanitizes the input and creates a valid TypeIdPrefix.

This method will remove invalid characters, convert to lowercase, and ensure the result conforms to the TypeID specification.

If the input is invalid and cannot be sanitized into a valid prefix, an empty TypeIdPrefix will be returned.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> Sanitize for T
where T: AsRef<str>,