forge_out_buffer

Function forge_out_buffer 

Source
pub fn forge_out_buffer(fix_version: &str) -> [u8; 1024]
Expand description

Create a pre-initialized buffer for FIX message writing with specified version.

This function returns a buffer that is already initialized with the version-specific FIX header structure.

§Arguments

  • fix_version - The FIX version string (e.g., “FIX.4.4”, “FIX.4.2”, “FIXT.1.1”)

§Buffer Layout Examples

For all FIX 4.x versions:

  • Bytes 0-9: BeginString “8=FIX.4.x\x01”
  • Bytes 10-16: BodyLength placeholder “9=0000\x01”
  • Bytes 17-19: MsgType tag “35=”
  • Bytes 20+: Available for MsgType value and remaining message content

§Example

let mut buffer = forge_out_buffer("FIX.4.4");

// Fixed header is already there, start writing MsgType value
let mut pos = FORGE_WRITE_START;
buffer[pos] = b'D'; pos += 1; // Just the MsgType value
buffer[pos] = 0x01; pos += 1; // SOH after MsgType
// ... continue writing other fields
// Finally, update BodyLength

§Performance

This function performs a single copy to initialize the entire fixed header structure. BeginString, BodyLength structure, and MsgType tag are never written again during message serialization.