Trait VecJsonExt

Source
pub trait VecJsonExt {
    // Required method
    fn parse_json(self) -> Result<OwnedValue>;
}
Expand description

Extension trait for Vec<u8> to add zero-allocation JSON parsing

This trait provides optimized JSON parsing for Vec<u8> by taking ownership and parsing in-place using SIMD-accelerated parsing, eliminating intermediate allocations.

§Usage

use rusty_feeder::exchange::zerocopy_helpers::VecJsonExt;

let json_data = r#"{"symbol":"BTC/USD","price":50000.0}"#.as_bytes().to_vec();
let parsed = json_data.parse_json()?;
assert_eq!(parsed["symbol"], "BTC/USD");

See module-level documentation for detailed performance characteristics and HFT optimization guidelines.

Required Methods§

Source

fn parse_json(self) -> Result<OwnedValue>

Parse JSON from a Vec<u8> with zero allocation

Takes ownership of the vector and parses the JSON in-place using SIMD-accelerated parsing. This is the most efficient method for parsing JSON from owned byte data.

§Arguments
  • self - The Vec<u8> containing UTF-8 encoded JSON data (consumed)
§Returns
  • Ok(OwnedValue) - Successfully parsed JSON value
  • Err(anyhow::Error) - Parse error with detailed error information
§Performance
  • Zero memory allocations for the parsing operation
  • SIMD-accelerated parsing (2-10x faster than standard parsers)
  • In-place mutation of the input buffer for optimal cache usage
§Examples
use rusty_feeder::exchange::zerocopy_helpers::VecJsonExt;

let json_data = r#"{"symbol":"BTC/USD","price":50000.0}"#.as_bytes().to_vec();
let parsed = json_data.parse_json()?;
assert_eq!(parsed["symbol"], "BTC/USD");

Implementations on Foreign Types§

Source§

impl VecJsonExt for Vec<u8>

Source§

fn parse_json(self) -> Result<OwnedValue>

Implementors§