Struct strict_encoding::FieldName

source ·
pub struct FieldName(/* private fields */);

Implementations§

source§

impl FieldName

source

pub fn as_str(&self) -> &str

Returns string reference.

source§

impl FieldName

source

pub fn to_ident(&self) -> Ident

Converts to identifier name.

source

pub fn into_ident(self) -> Ident

Converts into identifier name.

Methods from Deref<Target = AsciiString>§

source

pub fn capacity(&self) -> usize

Returns the number of bytes that this ASCII string buffer can hold without reallocating.

§Examples
let s = String::with_capacity(10);
assert!(s.capacity() >= 10);
source

pub fn len(&self) -> usize

Returns the number of bytes in this ASCII string.

§Examples
let s = AsciiString::from_ascii("foo").unwrap();
assert_eq!(s.len(), 3);
source

pub fn is_empty(&self) -> bool

Returns true if the ASCII string contains zero bytes.

§Examples
let mut s = AsciiString::new();
assert!(s.is_empty());
s.push(AsciiChar::from_ascii('a').unwrap());
assert!(!s.is_empty());

Methods from Deref<Target = AsciiStr>§

source

pub fn as_str(&self) -> &str

Converts &self to a &str slice.

source

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

Converts &self into a byte slice.

source

pub fn as_slice(&self) -> &[AsciiChar]

Returns the entire string as slice of AsciiChars.

source

pub fn as_mut_slice(&mut self) -> &mut [AsciiChar]

Returns the entire string as mutable slice of AsciiChars.

source

pub fn as_ptr(&self) -> *const AsciiChar

Returns a raw pointer to the AsciiStr’s buffer.

The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the AsciiStr may cause it’s buffer to be reallocated, which would also make any pointers to it invalid.

source

pub fn as_mut_ptr(&mut self) -> *mut AsciiChar

Returns an unsafe mutable pointer to the AsciiStr’s buffer.

The caller must ensure that the slice outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the AsciiStr may cause it’s buffer to be reallocated, which would also make any pointers to it invalid.

source

pub fn to_ascii_string(&self) -> AsciiString

Available on crate feature alloc only.

Copies the content of this AsciiStr into an owned AsciiString.

source

pub fn len(&self) -> usize

Returns the number of characters / bytes in this ASCII sequence.

§Examples
let s = AsciiStr::from_ascii("foo").unwrap();
assert_eq!(s.len(), 3);
source

pub fn is_empty(&self) -> bool

Returns true if the ASCII slice contains zero bytes.

§Examples
let mut empty = AsciiStr::from_ascii("").unwrap();
let mut full = AsciiStr::from_ascii("foo").unwrap();
assert!(empty.is_empty());
assert!(!full.is_empty());
source

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

Returns an iterator over the characters of the AsciiStr.

source

pub fn chars_mut(&mut self) -> CharsMut<'_>

Returns an iterator over the characters of the AsciiStr which allows you to modify the value of each AsciiChar.

source

pub fn split(&self, on: AsciiChar) -> impl DoubleEndedIterator

Returns an iterator over parts of the AsciiStr separated by a character.

§Examples
let words = AsciiStr::from_ascii("apple banana lemon").unwrap()
    .split(AsciiChar::Space)
    .map(|a| a.as_str())
    .collect::<Vec<_>>();
assert_eq!(words, ["apple", "banana", "lemon"]);
source

pub fn lines(&self) -> impl DoubleEndedIterator

Returns an iterator over the lines of the AsciiStr, which are themselves AsciiStrs.

Lines are ended with either LineFeed (\n), or CarriageReturn then LineFeed (\r\n).

The final line ending is optional.

source

pub fn trim(&self) -> &AsciiStr

Returns an ASCII string slice with leading and trailing whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("white \tspace", example.trim());
source

pub fn trim_start(&self) -> &AsciiStr

Returns an ASCII string slice with leading whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("white \tspace  \t", example.trim_start());
source

pub fn trim_end(&self) -> &AsciiStr

Returns an ASCII string slice with trailing whitespace removed.

§Examples
let example = AsciiStr::from_ascii("  \twhite \tspace  \t").unwrap();
assert_eq!("  \twhite \tspace", example.trim_end());
source

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

Compares two strings case-insensitively.

source

pub fn make_ascii_uppercase(&mut self)

Replaces lowercase letters with their uppercase equivalent.

source

pub fn make_ascii_lowercase(&mut self)

Replaces uppercase letters with their lowercase equivalent.

source

pub fn to_ascii_uppercase(&self) -> AsciiString

Available on crate feature alloc only.

Returns a copy of this string where letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’.

source

pub fn to_ascii_lowercase(&self) -> AsciiString

Available on crate feature alloc only.

Returns a copy of this string where letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’.

source

pub fn first(&self) -> Option<AsciiChar>

Returns the first character if the string is not empty.

source

pub fn last(&self) -> Option<AsciiChar>

Returns the last character if the string is not empty.

Trait Implementations§

source§

impl AsRef<RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>> for FieldName

source§

fn as_ref(&self) -> &RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>

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

impl AsRef<str> for FieldName

source§

fn as_ref(&self) -> &str

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

impl Borrow<RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>> for FieldName

source§

fn borrow(&self) -> &RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>

Immutably borrows from an owned value. Read more
source§

impl Borrow<str> for FieldName

source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
source§

impl Clone for FieldName

source§

fn clone(&self) -> FieldName

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for FieldName

source§

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

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

impl Deref for FieldName

source§

type Target = RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for FieldName

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Display for FieldName

source§

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

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

impl From<&'static str> for FieldName

source§

fn from(ident: &'static str) -> Self

Converts to this type from the input type.
source§

impl From<FieldName> for Ident

source§

fn from(name: FieldName) -> Self

Converts to this type from the input type.
source§

impl From<FieldName> for RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>

source§

fn from(wrapped: FieldName) -> Self

Converts to this type from the input type.
source§

impl From<FieldName> for String

source§

fn from(ident: FieldName) -> String

Converts to this type from the input type.
source§

impl From<RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>> for FieldName

source§

fn from(v: RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>) -> Self

Converts to this type from the input type.
source§

impl FromStr for FieldName

source§

type Err = <<FieldName as Wrapper>::Inner as FromStr>::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 Hash for FieldName

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 Ord for FieldName

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · source§

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

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

impl PartialEq for FieldName

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd for FieldName

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Serialize for FieldName

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl StrictDecode for FieldName

source§

fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError>

source§

fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>

source§

impl StrictDumb for FieldName

source§

fn strict_dumb() -> Self

source§

impl StrictEncode for FieldName

source§

fn strict_encode<W: TypedWrite>(&self, writer: W) -> Result<W>

source§

fn strict_write(&self, writer: impl WriteRaw) -> Result<()>

source§

impl StrictTuple for FieldName

source§

impl StrictType for FieldName

source§

const STRICT_LIB_NAME: &'static str = STRICT_TYPES_LIB

source§

fn strict_name() -> Option<TypeName>

source§

impl TryFrom<String> for FieldName

source§

type Error = InvalidRString

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

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

Performs the conversion.
source§

impl Wrapper for FieldName

source§

type Inner = RString<AlphaSmallLodash, AlphaNumLodash, 1, IDENT_MAX_LEN>

Inner type wrapped by the current newtype
source§

fn from_inner(inner: Self::Inner) -> Self

Instantiates wrapper type with the inner data
source§

fn as_inner(&self) -> &Self::Inner

Returns reference to the inner representation for the wrapper type
source§

fn into_inner(self) -> Self::Inner

Unwraps the wrapper returning the inner type
source§

fn to_inner(&self) -> Self::Inner
where Self::Inner: Clone,

Clones inner data of the wrapped type and return them
source§

impl Eq for FieldName

source§

impl StrictProduct for FieldName

source§

impl StructuralPartialEq for FieldName

Auto Trait Implementations§

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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§

default 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.
source§

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