Struct easyfix_messages::fields::FixString
source · pub struct FixString(_);
Implementations§
source§impl FixString
impl FixString
pub const fn new() -> FixString
pub fn with_capacity(capacity: usize) -> FixString
sourcepub fn from_ascii(buf: Vec<u8>) -> Result<FixString, FixStringError>
pub fn from_ascii(buf: Vec<u8>) -> Result<FixString, FixStringError>
Converts a vector of bytes to a FixString
.
A FIX string (FixString
) is made of bytes (u8
),
and a vector of bytes (Vec<u8>
) is made of bytes, so this function
converts between the two. Not all byte slices are valid FixString
s,
however: FixString
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.
This method will take care to not copy the vector, for efficiency’s sake.
If you need a &FixStr
instead of a FixString
, consider
FixStr::from_ascii
.
The inverse of this method is into_bytes
.
Errors
Returns Err
if the slice is not ASCII with a description as to why
the provided bytes are not ASCII.
sourcepub unsafe fn from_ascii_unchecked(buf: Vec<u8>) -> FixString
pub unsafe fn from_ascii_unchecked(buf: Vec<u8>) -> FixString
Converts a vector of bytes to a FixString
without checking that the
it contains only ASCII characters.
See the safe version, from_ascii
, for more details.
Safety
This function is unsafe because it does not check that the bytes passed
to it are valid ASCII. If this constraint is violated, it may cause
memory unsafety issues with future users of the FixString
,
as the rest of the library assumes that FixString
s are valid ASCII.
pub fn from_ascii_lossy(buf: Vec<u8>) -> FixString
pub fn as_utf8(&self) -> &str
pub fn into_utf8(self) -> String
pub fn into_bytes(self) -> Vec<u8>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Methods from Deref<Target = FixStr>§
Trait Implementations§
source§impl<'de> Deserialize<'de> for FixString
impl<'de> Deserialize<'de> for FixString
source§fn deserialize<D>(deserializer: D) -> Result<FixString, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<FixString, D::Error>where
D: Deserializer<'de>,
source§impl Ord for FixString
impl Ord for FixString
source§impl<const N: usize> PartialEq<&[u8; N]> for FixString
impl<const N: usize> PartialEq<&[u8; N]> for FixString
source§impl PartialEq<&[u8]> for FixString
impl PartialEq<&[u8]> for FixString
source§impl PartialEq<&FixStr> for FixString
impl PartialEq<&FixStr> for FixString
source§impl PartialEq<&str> for FixString
impl PartialEq<&str> for FixString
source§impl<const N: usize> PartialEq<[u8; N]> for FixString
impl<const N: usize> PartialEq<[u8; N]> for FixString
source§impl PartialEq<[u8]> for FixString
impl PartialEq<[u8]> for FixString
source§impl PartialEq<FixStr> for FixString
impl PartialEq<FixStr> for FixString
source§impl PartialEq<FixString> for FixString
impl PartialEq<FixString> for FixString
source§impl PartialEq<String> for FixString
impl PartialEq<String> for FixString
source§impl PartialEq<Vec<u8, Global>> for FixString
impl PartialEq<Vec<u8, Global>> for FixString
source§impl PartialOrd<FixString> for FixString
impl PartialOrd<FixString> for FixString
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