Skip to main content

FieldRef

Struct FieldRef 

Source
pub struct FieldRef<'a> {
    pub tag: u32,
    pub value: &'a [u8],
}
Expand description

Zero-copy reference to a field within a FIX message buffer.

This struct holds references to the original message buffer, avoiding allocation during parsing.

Fields§

§tag: u32

The field tag number.

§value: &'a [u8]

Reference to the field value bytes (without delimiters).

Implementations§

Source§

impl<'a> FieldRef<'a>

Source

pub const fn new(tag: u32, value: &'a [u8]) -> Self

Creates a new field reference.

§Arguments
  • tag - The field tag number
  • value - Reference to the value bytes
Source

pub const fn tag(&self) -> FieldTag

Returns the field tag.

Source

pub fn as_str(&self) -> Result<&'a str, DecodeError>

Returns the value as a string slice.

§Errors

Returns DecodeError::InvalidUtf8 if the value is not valid UTF-8.

Source

pub fn to_string(&self) -> Result<String, DecodeError>

Returns the value as an owned String.

§Errors

Returns DecodeError::InvalidUtf8 if the value is not valid UTF-8.

Source

pub fn parse<T: FromStr>(&self) -> Result<T, DecodeError>

Parses the value as the specified type.

§Errors

Returns DecodeError::InvalidFieldValue if parsing fails.

Source

pub fn as_u64(&self) -> Result<u64, DecodeError>

Returns the value as a u64.

§Errors

Returns DecodeError::InvalidFieldValue if the value is not a valid integer.

Source

pub fn as_i64(&self) -> Result<i64, DecodeError>

Returns the value as an i64.

§Errors

Returns DecodeError::InvalidFieldValue if the value is not a valid integer.

Source

pub fn as_decimal(&self) -> Result<Decimal, DecodeError>

Returns the value as a Decimal.

§Errors

Returns DecodeError::InvalidFieldValue if the value is not a valid decimal.

Source

pub fn as_bool(&self) -> Result<bool, DecodeError>

Returns the value as a bool (FIX uses ‘Y’/‘N’).

§Errors

Returns DecodeError::InvalidFieldValue if the value is not ‘Y’ or ‘N’.

Source

pub fn as_char(&self) -> Result<char, DecodeError>

Returns the value as a single character.

§Errors

Returns DecodeError::InvalidFieldValue if the value is not a single ASCII character.

Source

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

Returns the raw bytes of the value.

Source

pub const fn len(&self) -> usize

Returns the length of the value in bytes.

Source

pub const fn is_empty(&self) -> bool

Returns true if the value is empty.

Trait Implementations§

Source§

impl<'a> Clone for FieldRef<'a>

Source§

fn clone(&self) -> FieldRef<'a>

Returns a duplicate 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<'a> Debug for FieldRef<'a>

Source§

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

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

impl<'a> Copy for FieldRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for FieldRef<'a>

§

impl<'a> RefUnwindSafe for FieldRef<'a>

§

impl<'a> Send for FieldRef<'a>

§

impl<'a> Sync for FieldRef<'a>

§

impl<'a> Unpin for FieldRef<'a>

§

impl<'a> UnwindSafe for FieldRef<'a>

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> 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, 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.