Struct easyfix_messages::fields::FixStr
source · pub struct FixStr(/* private fields */);Implementations§
source§impl FixStr
impl FixStr
sourcepub fn from_ascii(buf: &[u8]) -> Result<&FixStr, FixStringError>
pub fn from_ascii(buf: &[u8]) -> Result<&FixStr, FixStringError>
Converts a slice of bytes to a string slice.
A FIX string slice (&FixStr) is made of bytes (u8), and a byte
slice (&[u8]) is made of bytes, so this function
converts between the two. Not all byte slices are valid string slices,
however: &FixStr requires that it is valid ASCII.
from_ascii() checks to ensure that the bytes are valid ASCII,
and then does the conversion.
If you are sure that the byte slice is valid ASCII, and you don’t want
to incur the overhead of the validity check, there is an unsafe version
of this function, from_ascii_unchecked, which has the same behavior
but skips the check.
If you need a FixString instead of a &FixStr, consider
FixString::from_ascii.
Because you can stack-allocate a [u8; N], and you can take a
&[u8] of it, this function is one way to have a
stack-allocated string.
Errors
Returns Err if the slice is not ASCII.
sourcepub const unsafe fn from_ascii_unchecked(buf: &[u8]) -> &FixStr
pub const unsafe fn from_ascii_unchecked(buf: &[u8]) -> &FixStr
Converts a slice of bytes to a FIX string slice without checking that it contains only ASCII characters.
See the safe version, from_ascii, for more information.
Safety
The bytes passed in must consists from ASCII characters only.
pub const fn as_utf8(&self) -> &str
pub const fn as_bytes(&self) -> &[u8] ⓘ
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Trait Implementations§
source§impl PartialEq<&[u8]> for FixStr
impl PartialEq<&[u8]> for FixStr
source§impl<const N: usize> PartialEq<&[u8; N]> for FixStr
impl<const N: usize> PartialEq<&[u8; N]> for FixStr
source§impl PartialEq<&FixStr> for FixString
impl PartialEq<&FixStr> for FixString
source§impl PartialEq<&str> for FixStr
impl PartialEq<&str> for FixStr
source§impl PartialEq<[u8]> for FixStr
impl PartialEq<[u8]> for FixStr
source§impl<const N: usize> PartialEq<[u8; N]> for FixStr
impl<const N: usize> PartialEq<[u8; N]> for FixStr
source§impl PartialEq<FixStr> for FixString
impl PartialEq<FixStr> for FixString
source§impl PartialEq<String> for FixStr
impl PartialEq<String> for FixStr
source§impl PartialEq<Vec<u8>> for FixStr
impl PartialEq<Vec<u8>> for FixStr
source§impl PartialEq for FixStr
impl PartialEq for FixStr
source§impl PartialOrd for FixStr
impl PartialOrd for FixStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more