Skip to main content

Module id

Module id 

Source
Expand description

Strongly-typed identifiers with SipHash integration

This module provides type-safe wrappers around numeric IDs that are derived from string names via SipHash. This provides both efficiency (4-byte IDs on wire) and type safety (can’t mix up different ID types).

§Examples

use synapse_primitives::id::{InterfaceId, MethodId, ServiceId, HeaderKeyId};

// Create IDs from names
let interface_id = InterfaceId::from_name("mensa.user.v2.UserInterface");
let method_id = MethodId::from_name("GetUser");
let service_id = ServiceId::from_name("user-service");
let header_id = HeaderKeyId::from_name("trace_id");

// Use in protobuf or network protocols
let wire_format: u32 = interface_id.into();
let restored = InterfaceId::from_raw(wire_format);
assert_eq!(interface_id, restored);

Modules§

well_known
Common header key IDs for standard headers

Structs§

HeaderKeyId
Header key identifier - represents a header name in RPC messages
InstanceId
Instance identifier - represents a specific running instance of a service
InterfaceId
Interface identifier - represents a protobuf-defined RPC interface
MethodId
Method identifier - represents a method within an RPC interface
MetricId
Metric identifier - represents a metric name for monitoring
ServiceId
Service identifier - represents a logical service unit