Crate static_id

source ·
Expand description

§StaticId

This library provides an extremely memory-efficient implementation of StaticId for handling interned identifiers with optimal performance.

§Features

  • StaticId: A highly optimized, interned identifier type combining a code and a venue.
  • Exceptional memory efficiency: Each StaticId is represented by a single 64-bit pointer.
  • Ultra-fast comparisons: Equality checks and hashing operations only compare 8 bytes, regardless of the actual string length.
  • Lazy evaluation: The actual string data is only accessed during serialization.

§Limitations

  • The code component of a StaticId cannot exceed 32 bytes.
  • The venue component of a StaticId cannot exceed 16 bytes.

§Usage

use static_id::StaticId;

let id = StaticId::from_str("AAPL", "NASDAQ");
assert_eq!(id.get_id().code.as_str(), "AAPL");
assert_eq!(id.get_id().venue.as_str(), "NASDAQ");
 
assert_eq!(id.code_str(), "AAPL");
assert_eq!(id.venue_str(), "NASDAQ");

// Fast equality check (compares only 8 bytes)
let id2 = StaticId::from_str("AAPL", "NASDAQ");
assert_eq!(id, id2);
println!("ID: {}", id); // => AAPL@NASDAQ

Re-exports§

Modules§

Structs§

Type Aliases§