Skip to main content

GString

Struct GString 

Source
pub struct GString<V: Validator = NoValidation, const MIN: usize = DEFAULT_MIN, const MAX: usize = DEFAULT_MAX, const ASCII_ONLY: bool = DEFAULT_ASCII_ONLY> { /* private fields */ }
Expand description

GString contains stack-allocated, Copy, bounded string along with ASCII toggle and embedded validation logic.

§Generic parameters:

  • V: Validator: default to NoValidation, it will validate the string upon creation and deserialization.
  • const MIN: usize: default to DEFAULT_MIN, in bytes, determine minimum length.
  • const MAX: usize: default to DEFAULT_MAX, in bytes, determine maximum length.
  • const ASCII_ONLY: bool: default to DEFAULT_ASCII_ONLY, determine whether GString may contains arbitrary or ASCII only UTF-8 encoded string.

§Usage

You can use this type in several ways:

  • Defaulted to default generic params: let a: GString = GString::try_new("anjay!!").unwrap().
  • Defaulted to default generic params with try_default(...): let a = GString::try_default("anjay!!").unwrap().
  • Using type aliases. You can declare some aliases matching the behavior you want: type Username = GString<UsernameValidation, 3, 20, true>.
  • Declaring each generic params from left to right. Declaration must be from left to right with omission allowed on right-most params: let a = GString::<(), 2>::try_new("anjay!!").unwrap().

§Examples

use g_string::{GString, Validator, GStringError};

let a: GString = GString::try_new("anjay!!").unwrap();
assert_eq!(a, "anjay!!");

let a = GString::try_default("anjay!!").unwrap();
assert_eq!(a, "anjay!!");

#[derive(Debug, Clone)]
struct UsernameValidation;

impl Validator for UsernameValidation {
    type Err = GStringError<&'static str>;

    fn validate(_: impl AsRef<str>) -> Result<(), Self::Err> {
        // some validation logics here...
        Ok(())
    }   
}

type Username = GString<UsernameValidation, 3, 20, true>;
let a = Username::try_new("wanjay!!🤣");
assert!(a.is_err()); // because '🤣' is not ASCII.

let a = GString::<(), 2, 4>::try_new("anjay!!");
assert!(a.is_err()); // MAX is 4.

Implementations§

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn try_from_iter<I, S>(iter: I) -> Result<Self, GStringError<V::Err>>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Construct GString from iterator of AsRef<str>.

§Examples
use g_string::GString;

let result: GString = GString::try_from_iter(["12", "3a"]).unwrap();
assert_eq!(result, "123a");
Source

pub fn try_from_chars<I>(iter: I) -> Result<Self, GStringError<V::Err>>
where I: IntoIterator<Item = char>,

Construct GString from iterator of chars

§Examples
use g_string::GString;

let result: GString = GString::try_from_chars(['a', 'b', 'c']).unwrap();
assert_eq!(result, "abc");
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn push(&mut self, ch: char) -> Result<(), GStringError<V::Err>>

Push a char at the end of string with invariants preserved.

Source

pub fn push_str(&mut self, s: &str) -> Result<(), GStringError<V::Err>>

Push string at the end of string with invariants preserved.

Source

pub fn insert( &mut self, idx: usize, ch: char, ) -> Result<(), GStringError<V::Err>>

Insert a char at specific index with invariants preserved.

Source

pub fn insert_str( &mut self, idx: usize, string: &str, ) -> Result<(), GStringError<V::Err>>

Insert string at specific index with invariants preserved.

Source

pub fn pop(&mut self) -> Result<Option<char>, GStringError<V::Err>>

Pop a char from the end of string with invariants preserved.

Source

pub fn remove(&mut self, idx: usize) -> Result<char, GStringError<V::Err>>

Removes a char at specific index with invariants preserved.

Source

pub fn truncate(&mut self, new_len: usize) -> Result<(), GStringError<V::Err>>

Truncates to a new length with invariants preserved.

Source

pub fn replace( &mut self, from: &str, to: &str, ) -> Result<(), GStringError<V::Err>>

Replaces from with to in string with invariants preserved.

Source

pub fn replace_range<R>( &mut self, range: R, replace_with: &str, ) -> Result<(), GStringError<V::Err>>
where R: RangeBounds<usize>,

Replaces with range with invariants preserved.

Source§

impl<V: Validator + AllowEmpty, const MAX: usize, const ASCII_ONLY: bool> GString<V, 0, MAX, ASCII_ONLY>

Source

pub fn clear(&mut self)

Clear the string, only work if Validator implements AllowEmpty and MIN == 0.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn try_extend<I, S>(&mut self, iter: I) -> Result<(), GStringError<V::Err>>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Extend existing string with iterator of AsRef<str> with invariants preserved.

§Examples
use g_string::GString;

let mut gs: GString<(), 0, 100, false> = GString::try_new("hello").unwrap();
gs.try_extend(["123", "456"].iter().copied());
assert_eq!(gs.as_str(), "hello123456");
Source

pub fn try_extend_chars<I>( &mut self, iter: I, ) -> Result<(), GStringError<V::Err>>
where I: IntoIterator<Item = char>,

Extend existing string with iterator of chars with invariants preserved.

§Examples
use g_string::GString;

let mut gs: GString<(), 0, 100, false> = GString::try_new("hello").unwrap();
gs.try_extend_chars(['@', 'z'].iter().copied());
assert_eq!(gs.as_str(), "hello@z");
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub const fn len(&self) -> usize

Get length of GString in bytes.

Source

pub const fn capacity(&self) -> usize

Tells maximum capacity returning MAX.

Source

pub fn count(&self) -> usize

Counts Unicode scalar values (char).

Source

pub const fn is_empty(&self) -> bool

Check if empty.

Source

pub const fn is_full(&self) -> bool

Tells if maximum capacity met.

Source

pub const fn is_char_boundary(&self, index: usize) -> bool

Source

pub const fn as_str(&self) -> &str

Show GString as &str.

Source

pub const fn as_bytes(&self) -> &[u8]

Show GString as bytes.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn grapheme_count(&self) -> usize

Counts user-perceived characters (grapheme clusters).

Source

pub fn graphemes(&self) -> Graphemes<'_>

Iterate over graphemes.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn chars(&self) -> Chars<'_>

Returns an iterator over the chars of a string slice.

Source

pub fn char_indices(&self) -> CharIndices<'_>

Returns an iterator over the chars of a string slice, and their positions.

Source

pub fn bytes(&self) -> Bytes<'_>

Returns an iterator over the bytes of a string slice.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn contains<P>(&self, pat: P) -> bool
where P: Pattern,

Source

pub fn starts_with<P>(&self, pat: P) -> bool
where P: Pattern,

Source

pub fn ends_with<P>(&self, pat: P) -> bool
where P: Pattern,

Source

pub fn find<P>(&self, pat: P) -> Option<usize>
where P: Pattern,

Source

pub fn rfind<P>(&self, pat: P) -> Option<usize>
where P: Pattern,

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn get<I>(&self, i: I) -> Option<&<I as SliceIndex<str>>::Output>
where I: SliceIndex<str>,

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn split<P: Pattern>(&self, pat: P) -> P::SplitIter<'_>

Returns an iterator over substrings of this string slice, separated by characters matched by a pattern.

Source

pub fn split_whitespace(&self) -> SplitWhitespace<'_>

Returns an iterator over the non-whitespace substrings of this string slice, separated by any amount of whitespace.

Source

pub fn lines(&self) -> Lines<'_>

Returns an iterator over the lines of this string slice.

Source

pub fn split_once<P: Pattern>(&self, delimiter: P) -> Option<(&str, &str)>

Divides this string slice into two at the first occurrence of a pattern.

Source

pub fn rsplit_once<P: Pattern>(&self, delimiter: P) -> Option<(&str, &str)>

Divides this string slice into two at the last occurrence of a pattern.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn try_trim(&self) -> Result<Self, GStringError<V::Err>>

Returns a trimmed copy of this string.

Source

pub fn try_trim_start(&self) -> Result<Self, GStringError<V::Err>>

Returns a copy of this string with leading whitespace removed.

Source

pub fn try_trim_end(&self) -> Result<Self, GStringError<V::Err>>

Returns a copy of this string with trailing whitespace removed.

Source

pub fn strip_prefix<P: Pattern>(&self, prefix: P) -> Option<&str>

Returns a string slice with the given prefix removed.

Source

pub fn strip_suffix<P: Pattern>(&self, suffix: P) -> Option<&str>

Returns a string slice with the given suffix removed.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn matches<P: Pattern>(&self, pat: P) -> P::MatchesIter<'_>

Returns an iterator over matches of a pattern within this string slice.

Source

pub fn rmatches<P: Pattern>(&self, pat: P) -> P::RMatchesIter<'_>

Returns an iterator over matches of a pattern within this string slice, yielded in reverse order.

Source

pub fn match_indices<P: Pattern>(&self, pat: P) -> P::MatchIndicesIter<'_>

Returns an iterator over the disjoint matches of a pattern and their positions within this string slice.

Source

pub fn rmatch_indices<P: Pattern>(&self, pat: P) -> P::RMatchIndicesIter<'_>

Returns an iterator over the disjoint matches of a pattern and their positions within this string slice, yielded in reverse order.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn parse<F>(&self) -> Result<F, F::Err>
where F: FromStr,

Parses this string slice into another type.

Source

pub fn is_ascii(&self) -> bool

Checks if all characters in this string are within the ASCII range.

Source

pub fn eq_ignore_ascii_case(&self, other: &str) -> bool

Compares two strings in a case-insensitive ASCII manner.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn escape_debug(&self) -> EscapeDebug<'_>

Returns an iterator that escapes this string using char::escape_debug.

Source

pub fn escape_default(&self) -> EscapeDefault<'_>

Returns an iterator that escapes this string using char::escape_default.

Source

pub fn escape_unicode(&self) -> EscapeUnicode<'_>

Returns an iterator that escapes this string using char::escape_unicode.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn encode_utf16(&self) -> EncodeUtf16<'_>

Returns an iterator of UTF-16 code units for this string slice.

Source§

impl GString

Source

pub fn try_default<S>(s: S) -> Result<Self, GStringError<Infallible>>
where S: AsRef<str>,

Construct with default generic params.

§Examples
use g_string::GString;

let a = GString::try_default("anjay!!").unwrap();
assert_eq!(a, "anjay!!");
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn try_new<S>(s: S) -> Result<Self, GStringError<V::Err>>
where S: AsRef<str>,

Construct new GString. All invariants from generic params will be imposed here.

§Examples
use g_string::GString;

let a: GString = GString::try_new("anjay!!").unwrap();
assert_eq!(a, "anjay!!");
Source

pub fn validate(self) -> Result<Self, GStringError<V::Err>>

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub const fn new(s: &str) -> InValidatedGString<V, MIN, MAX, ASCII_ONLY>

Construct GString in const context returning invalidated string. Validate the return to get GString.

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> GString<V, MIN, MAX, ASCII_ONLY>

Source

pub fn zeroize(&mut self)

Trait Implementations§

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> AsRef<[u8]> for GString<V, MIN, MAX, ASCII_ONLY>

GString AS &[u8]

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> AsRef<str> for GString<V, MIN, MAX, ASCII_ONLY>

GString AS &str

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Borrow<str> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl<V: Clone + Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Clone for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn clone(&self) -> GString<V, MIN, MAX, ASCII_ONLY>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Copy + Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Copy for GString<V, MIN, MAX, ASCII_ONLY>

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Debug for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Validator + AllowEmpty, const MAX: usize, const ASCII_ONLY: bool> Default for GString<V, 0, MAX, ASCII_ONLY>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Deserialize<'de> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Display for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Eq + Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Eq for GString<V, MIN, MAX, ASCII_ONLY>

Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> From<GString<V, MIN, MAX, ASCII_ONLY>> for String

Available on crate feature alloc only.

GString -> String

Source§

fn from(value: GString<V, MIN, MAX, ASCII_ONLY>) -> Self

Converts to this type from the input type.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> FromStr for GString<V, MIN, MAX, ASCII_ONLY>

&str -> GString

Source§

type Err = GStringError<<V as Validator>::Err>

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Hash for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> IntoIterator for &'a GString<V, MIN, MAX, ASCII_ONLY>
where V: Validator,

Iterates over the characters of a borrowed GString.

This behaves the same as iterating over &str.

§Examples

for ch in &gstring {
    // ch: char
}
Source§

type Item = char

The type of the elements being iterated over.
Source§

type IntoIter = Chars<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> IntoIterator for &'a mut GString<V, MIN, MAX, ASCII_ONLY>
where V: Validator,

Iterates over the characters of a mutably borrowed GString.

Even though the string is mutably borrowed, iteration yields immutable char values.

§Examples

for ch in &mut gstring {
    // ch: char
}
Source§

type Item = char

The type of the elements being iterated over.
Source§

type IntoIter = Chars<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> IntoIterator for GString<V, MIN, MAX, ASCII_ONLY>
where V: Validator,

Iterates over the characters of an owned GString.

This consumes the string.

§Examples

for ch in gstring {
    // ch: char
}
Source§

type Item = char

The type of the elements being iterated over.
Source§

type IntoIter = IntoChars<V, MIN, MAX, ASCII_ONLY>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<V: Validator + Eq, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Ord for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<&str> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<LHSV: Validator, RHSV: Validator, const LMIN: usize, const LMAX: usize, const LASCII: bool, const RMIN: usize, const RMAX: usize, const RASCII: bool> PartialEq<GString<RHSV, RMIN, RMAX, RASCII>> for GString<LHSV, LMIN, LMAX, LASCII>

Source§

fn eq(&self, other: &GString<RHSV, RMIN, RMAX, RASCII>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for &str

Source§

fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for String

Available on crate feature alloc only.
Source§

fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<GString<V, MIN, MAX, ASCII_ONLY>> for str

Source§

fn eq(&self, other: &GString<V, MIN, MAX, ASCII_ONLY>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<String> for GString<V, MIN, MAX, ASCII_ONLY>

Available on crate feature alloc only.
Source§

fn eq(&self, other: &String) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialEq<str> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<&str> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn partial_cmp(&self, other: &&str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<LHSV: Validator, RHSV: Validator, const LMIN: usize, const LMAX: usize, const LASCII: bool, const RMIN: usize, const RMAX: usize, const RASCII: bool> PartialOrd<GString<RHSV, RMIN, RMAX, RASCII>> for GString<LHSV, LMIN, LMAX, LASCII>

Source§

fn partial_cmp( &self, other: &GString<RHSV, RMIN, RMAX, RASCII>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for &str

Source§

fn partial_cmp( &self, other: &GString<V, MIN, MAX, ASCII_ONLY>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for String

Available on crate feature alloc only.
Source§

fn partial_cmp( &self, other: &GString<V, MIN, MAX, ASCII_ONLY>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<GString<V, MIN, MAX, ASCII_ONLY>> for str

Source§

fn partial_cmp( &self, other: &GString<V, MIN, MAX, ASCII_ONLY>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<String> for GString<V, MIN, MAX, ASCII_ONLY>

Available on crate feature alloc only.
Source§

fn partial_cmp(&self, other: &String) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> PartialOrd<str> for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Serialize for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> TryFrom<&str> for GString<V, MIN, MAX, ASCII_ONLY>

&str -> GString (try_into)

Source§

type Error = GStringError<<V as Validator>::Err>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> TryFrom<Cow<'a, str>> for GString<V, MIN, MAX, ASCII_ONLY>

Available on crate feature alloc only.
Source§

type Error = GStringError<<V as Validator>::Err>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Cow<'a, str>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<GSTRINGV: Validator, GSECRETV: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> TryFrom<GString<GSTRINGV, MIN, MAX, ASCII_ONLY>> for GSecret<GSECRETV, MIN, MAX, ASCII_ONLY>

Source§

type Error = GStringError<<GSECRETV as Validator>::Err>

The type returned in the event of a conversion error.
Source§

fn try_from( value: GString<GSTRINGV, MIN, MAX, ASCII_ONLY>, ) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> TryFrom<String> for GString<V, MIN, MAX, ASCII_ONLY>

Available on crate feature alloc only.

String -> GString

Source§

type Error = GStringError<<V as Validator>::Err>

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<V: Validator, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Write for GString<V, MIN, MAX, ASCII_ONLY>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Freeze for GString<V, MIN, MAX, ASCII_ONLY>

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> RefUnwindSafe for GString<V, MIN, MAX, ASCII_ONLY>
where V: RefUnwindSafe,

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Send for GString<V, MIN, MAX, ASCII_ONLY>
where V: Send,

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Sync for GString<V, MIN, MAX, ASCII_ONLY>
where V: Sync,

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> Unpin for GString<V, MIN, MAX, ASCII_ONLY>
where V: Unpin,

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> UnsafeUnpin for GString<V, MIN, MAX, ASCII_ONLY>

§

impl<V, const MIN: usize, const MAX: usize, const ASCII_ONLY: bool> UnwindSafe for GString<V, MIN, MAX, ASCII_ONLY>
where V: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.