Struct pascal_string::PascalString
[−]
[src]
pub struct PascalString { /* fields omitted */ }
An owned PascalString
. This string type stores its data the stack. It is always 256 bytes long, with
the first byte storing the length.
This string type uses Ascii encoding.
Methods
impl PascalString
[src]
pub fn new() -> Self
[src]
Creates a new, empty PascalString
.
pub fn from_fixed_ascii_array<C>(
string_len: u8,
char_array: [C; 255]
) -> Result<Self, PascalStringCreateError> where
C: ToAsciiChar + Clone,
[src]
string_len: u8,
char_array: [C; 255]
) -> Result<Self, PascalStringCreateError> where
C: ToAsciiChar + Clone,
Create a new PascalString
from its constituent parts: string_len
and char_array
.
Returns an Err
if char_array
is not valid Ascii.
pub fn from<B: AsRef<[u8]>>(bytes: B) -> Result<Self, PascalStringCreateError>
[src]
Create a new PascalString
using the contents of bytes
.
Returns an Err
if bytes
is longer than 255 characters, or it does not contain
Ascii encoded characters.
pub fn push<C: ToAsciiChar>(&mut self, character: C)
[src]
Push an ascii convertible character onto this string.
Panics
Panics if the string is full, of if the character
is not a valid ascii character.
pub fn try_push<C: ToAsciiChar>(
&mut self,
character: C
) -> Result<(), PascalStringAppendError>
[src]
&mut self,
character: C
) -> Result<(), PascalStringAppendError>
Attempt to push an ascii convertible character onto the end of this PascalString
.
Returns Err(_)
if the character cannot be pushed because this PascalString
is full, or if
character
is not a valid ascii character.
pub fn push_str<S: AsRef<str>>(&mut self, s: S)
[src]
Append a given string slice onto the end of this PascalString
.
Panics
Panics if the string cannot be pushed to because this PascalString
is full.
pub fn try_push_str<S: AsRef<str>>(
&mut self,
s: S
) -> Result<(), PascalStringAppendError>
[src]
&mut self,
s: S
) -> Result<(), PascalStringAppendError>
Attempt to append a given string slice onto the end of this PascalString
.
Returns Err(_)
if the string cannot be pushed because this PascalString
is full.
pub fn pop(&mut self) -> Option<AsciiChar>
[src]
Removes the last character from the string buffer and returns it.
Returns None
if this PascalString
is empty.
pub fn remove(&mut self, index: u8) -> AsciiChar
[src]
Remove a character from the AsciiString
at index
.
Panics
Panics if index
is larger than self.len()
, or if self.is_empty()
is true
.
pub fn insert<C: ToAsciiChar>(&mut self, ch: C, index: u8)
[src]
Insert a character into the AsciiString
at index
.
Panics
Panics if index
is larger than self.len()
, or if the PascalString
is full.
pub fn clear(&mut self)
[src]
Truncates this String, removing all contents.
Does not zero the values of the string.
pub fn to_array(self) -> [u8; 256]
[src]
Consumes this PascalString
, and returns its inner state as a [u8; 256]
, where the first byte
is the length.
Note that if the string has been truncated, bytes beyond the end of the string will not have been zeroed.
Methods from Deref<Target = PascalStr>
pub fn as_ptr(&self) -> *const AsciiChar
[src]
Get a pointer to the first byte of the string buffer.
pub fn as_mut_ptr(&mut self) -> *mut AsciiChar
[src]
Get a mutable pointer to the first byte of the string buffer.
pub fn as_str(&self) -> &str
[src]
Get the PascalStr
as an immutable &str
reference.
pub fn as_cstr(&self) -> Result<Cow<CStr>, InteriorNullError>
[src]
Get this string as a CStr
.
Returns Err(InteriorNullError)
if the string contains any interior nulls. If this string is full,
then a new CString
will be allocated to hold the trailing null byte.
pub fn len(&self) -> usize
[src]
Returns the number of characters used in the string.
pub fn is_empty(&self) -> bool
[src]
Returns true if the string has a length of 0
pub fn is_full(&self) -> bool
[src]
Returns true if the string has a length of 255.
When this value is true, no more elements can be pushed onto the string.
ⓘImportant traits for Chars<'a>pub fn chars<'a>(&'a self) -> Chars<'a>
[src]
Get an immutable iterator to the internal character array.
ⓘImportant traits for CharsMut<'a>pub fn chars_mut<'a>(&'a mut self) -> CharsMut<'a>
[src]
Get a mutable iterator to the internal character array.
ⓘImportant traits for Lines<'a>pub fn lines(&self) -> Lines
[src]
Get an iterator over the lines of the internal character array.
pub fn get_unchecked(&self, index: usize) -> AsciiChar
[src]
Get a character in the string, without checking if the index is within the bounds of len()
.
This method cannot cause memory unsafety because index
is bounds checked within the maximum possible
length of the PascalStr
, which means that it cannot read uninitialised memory. However, it can give access
to stale characters if index
is greater than or equal to self.len()
or isize::MAX
, and self.is_full()
is false
.
Panics
This method will panic if index
is larger than u8::MAX
(255).
Trait Implementations
impl Eq for PascalString
[src]
impl Default for PascalString
[src]
impl Clone for PascalString
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<S: AsRef<PascalStr> + ?Sized> PartialEq<S> for PascalString
[src]
fn eq(&self, other: &S) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Ord for PascalString
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<S: AsRef<PascalStr> + ?Sized> PartialOrd<S> for PascalString
[src]
fn partial_cmp(&self, other: &S) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for PascalString
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl AsciiExt for PascalString
[src]
type Owned = Self
Container type for copied ASCII characters.
fn is_ascii(&self) -> bool
[src]
Checks if the value is within the ASCII range. Read more
fn to_ascii_uppercase(&self) -> Self::Owned
[src]
Makes a copy of the value in its ASCII upper case equivalent. Read more
fn to_ascii_lowercase(&self) -> Self::Owned
[src]
Makes a copy of the value in its ASCII lower case equivalent. Read more
fn eq_ignore_ascii_case(&self, other: &Self) -> bool
[src]
Checks that two values are an ASCII case-insensitive match. Read more
fn make_ascii_uppercase(&mut self)
[src]
Converts this type to its ASCII upper case equivalent in-place. Read more
fn make_ascii_lowercase(&mut self)
[src]
Converts this type to its ASCII lower case equivalent in-place. Read more
fn is_ascii_alphabetic(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII alphabetic character: U+0041 'A' ... U+005A 'Z' or U+0061 'a' ... U+007A 'z'. For strings, true if all characters in the string are ASCII alphabetic. Read more
fn is_ascii_uppercase(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII uppercase character: U+0041 'A' ... U+005A 'Z'. For strings, true if all characters in the string are ASCII uppercase. Read more
fn is_ascii_lowercase(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII lowercase character: U+0061 'a' ... U+007A 'z'. For strings, true if all characters in the string are ASCII lowercase. Read more
fn is_ascii_alphanumeric(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII alphanumeric character: U+0041 'A' ... U+005A 'Z', U+0061 'a' ... U+007A 'z', or U+0030 '0' ... U+0039 '9'. For strings, true if all characters in the string are ASCII alphanumeric. Read more
fn is_ascii_digit(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII decimal digit: U+0030 '0' ... U+0039 '9'. For strings, true if all characters in the string are ASCII digits. Read more
fn is_ascii_hexdigit(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII hexadecimal digit: U+0030 '0' ... U+0039 '9', U+0041 'A' ... U+0046 'F', or U+0061 'a' ... U+0066 'f'. For strings, true if all characters in the string are ASCII hex digits. Read more
fn is_ascii_punctuation(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII punctuation character: Read more
fn is_ascii_graphic(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII graphic character: U+0021 '!' ... U+007E '~'. For strings, true if all characters in the string are ASCII graphic characters. Read more
fn is_ascii_whitespace(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII whitespace character: U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED, U+000C FORM FEED, or U+000D CARRIAGE RETURN. For strings, true if all characters in the string are ASCII whitespace. Read more
fn is_ascii_control(&self) -> bool
[src]
ascii_ctype
)Checks if the value is an ASCII control character: U+0000 NUL ... U+001F UNIT SEPARATOR, or U+007F DELETE. Note that most ASCII whitespace characters are control characters, but SPACE is not. Read more
impl Debug for PascalString
[src]
fn fmt(&self, fmtr: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Display for PascalString
[src]
fn fmt(&self, fmtr: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Deref for PascalString
[src]
type Target = PascalStr
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.
impl DerefMut for PascalString
[src]
impl AsRef<PascalStr> for PascalString
[src]
impl AsRef<str> for PascalString
[src]
impl AsRef<[u8]> for PascalString
[src]
impl AsRef<AsciiStr> for PascalString
[src]
impl AsRef<[AsciiChar]> for PascalString
[src]
impl AsMut<[AsciiChar]> for PascalString
[src]
impl Borrow<PascalStr> for PascalString
[src]
impl BorrowMut<PascalStr> for PascalString
[src]
fn borrow_mut(&mut self) -> &mut PascalStr
[src]
Mutably borrows from an owned value. Read more
impl Borrow<str> for PascalString
[src]
impl Borrow<[u8]> for PascalString
[src]
impl Borrow<AsciiStr> for PascalString
[src]
impl Borrow<[AsciiChar]> for PascalString
[src]
impl BorrowMut<[AsciiChar]> for PascalString
[src]
impl Into<[u8; 256]> for PascalString
[src]
impl Into<String> for PascalString
[src]
impl Into<Vec<u8>> for PascalString
[src]
impl Into<Vec<AsciiChar>> for PascalString
[src]
impl Into<AsciiString> for PascalString
[src]
fn into(self) -> AsciiString
[src]
Performs the conversion.
impl FromStr for PascalString
[src]
type Err = PascalStringCreateError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl FromIterator<AsciiChar> for PascalString
[src]
fn from_iter<I: IntoIterator<Item = AsciiChar>>(iter: I) -> Self
[src]
Creates a value from an iterator. Read more