pub struct StreamId(/* private fields */);Expand description
An append-only event stream identifier.
Streams are named with a category prefix so routing and partitioning are
explicit (e.g. process/{tenant_id}/{process_id}, partner/{partner_id}).
Implementations§
Source§impl StreamId
impl StreamId
Sourcepub fn new(id: impl Into<Box<str>>) -> Self
pub fn new(id: impl Into<Box<str>>) -> Self
Construct a stream identifier from any string-like value.
§Panics
Panics if id is empty or contains a NUL byte (\0).
Use this constructor only for compile-time literals where the value
is statically known to be valid. For runtime/externally-supplied strings
use StreamId::try_new or the typed constructors
(StreamId::for_process, StreamId::for_partner).
Sourcepub fn try_new(id: impl Into<Box<str>>) -> Result<Self, EngineError>
pub fn try_new(id: impl Into<Box<str>>) -> Result<Self, EngineError>
Fallible constructor — returns Err instead of panicking.
Prefer this over StreamId::new whenever the input string originates
from user input, network data, or storage. The typed constructors
(StreamId::for_process, StreamId::for_partner) call this
internally.
§Errors
Returns crate::error::EngineError::InvalidStreamId if id is empty or contains
a NUL byte.
Sourcepub fn for_process(tenant_id: TenantId, process_id: &ProcessId) -> Self
pub fn for_process(tenant_id: TenantId, process_id: &ProcessId) -> Self
Canonical stream for a process instance: process/{tenant_id}/{process_id}.
The tenant discriminator prevents cross-tenant event leakage when
list_streams is called with a tenant-scoped prefix
(process/{tenant_id}/).
Sourcepub fn for_partner(partner_id: &str) -> Result<Self, EngineError>
pub fn for_partner(partner_id: &str) -> Result<Self, EngineError>
Canonical stream for a market partner: partner/{partner_id}.
§Errors
Returns an error if partner_id contains / or a NUL byte, which
would escape the partner/ prefix used for range scans.