pub struct MessageBuilder<const IS_INIT: bool> { /* private fields */ }Expand description
Generic builder for constructing Message instances.
The builder supports chaining calls to add header or body fields.
Type-state (IS_INIT) tracks whether at least one body field was added,
allowing MessageBuilder::build() to only be available after initialization.
Implementations§
Source§impl<const IS_INIT: bool> MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> MessageBuilder<IS_INIT>
Sourcepub fn with_header(self, field: Field) -> Self
pub fn with_header(self, field: Field) -> Self
Adds a field to the message header.
Sourcepub fn with_field(self, field: Field) -> MessageBuilder<true>
pub fn with_field(self, field: Field) -> MessageBuilder<true>
Source§impl MessageBuilder<true>
impl MessageBuilder<true>
Sourcepub fn build(self) -> Message
pub fn build(self) -> Message
Finalizes and returns the fully constructed Message.
Example usage:
use trafix_codec::message::{
Message,
field::{
Field,
value::{begin_string::BeginString, msg_type::MsgType},
},
};
let msg = Message::builder(BeginString::FIX44, MsgType::Logout)
.with_field(Field::Custom { tag: 58, value: b"Bye".to_vec() })
.build();Auto Trait Implementations§
impl<const IS_INIT: bool> Freeze for MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> RefUnwindSafe for MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> Send for MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> Sync for MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> Unpin for MessageBuilder<IS_INIT>
impl<const IS_INIT: bool> UnwindSafe for MessageBuilder<IS_INIT>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more