pub struct StreamLayout { /* private fields */ }Expand description
Manages the on-disk directory layout for aggregate event streams.
The layout follows this structure:
<base_dir>/
streams/
<aggregate_type>/
<instance_id>/ -- standard eventfold log directory
app.jsonl
views/
projections/
<projection_name>/
meta/
streams.jsonl -- stream registryStreamLayout is cheap to clone (it wraps a single PathBuf) and provides
path helpers plus stream lifecycle management (creation and listing).
Implementations§
Source§impl StreamLayout
impl StreamLayout
Sourcepub fn new(base_dir: impl Into<PathBuf>) -> Self
pub fn new(base_dir: impl Into<PathBuf>) -> Self
Create a new StreamLayout rooted at the given base directory.
§Arguments
base_dir- Root directory for all event store data. The directory does not need to exist yet; it will be created lazily whenensure_streamis called.
Sourcepub fn stream_dir(&self, aggregate_type: &str, instance_id: &str) -> PathBuf
pub fn stream_dir(&self, aggregate_type: &str, instance_id: &str) -> PathBuf
Sourcepub fn projections_dir(&self) -> PathBuf
pub fn projections_dir(&self) -> PathBuf
Sourcepub fn process_managers_dir(&self) -> PathBuf
pub fn process_managers_dir(&self) -> PathBuf
Sourcepub fn ensure_stream(
&self,
aggregate_type: &str,
instance_id: &str,
) -> Result<PathBuf>
pub fn ensure_stream( &self, aggregate_type: &str, instance_id: &str, ) -> Result<PathBuf>
Ensures that the stream directory and registry entry exist for the given aggregate type and instance ID.
This method is idempotent: calling it multiple times with the same arguments will not create duplicate directory trees or registry entries.
§Arguments
aggregate_type- The aggregate type name (e.g."order").instance_id- The unique instance identifier within that type.
§Returns
The stream directory path on success.
§Errors
Returns std::io::Error if directory creation or file I/O fails.
Sourcepub fn list_streams(&self, aggregate_type: &str) -> Result<Vec<String>>
pub fn list_streams(&self, aggregate_type: &str) -> Result<Vec<String>>
Lists all instance IDs for the given aggregate type.
§Arguments
aggregate_type- The aggregate type name to list instances for.
§Returns
A sorted Vec<String> of instance IDs. Returns an empty vector
if the aggregate type directory does not exist.
§Errors
Returns std::io::Error if reading the directory fails for a reason
other than the directory not existing.
Trait Implementations§
Source§impl Clone for StreamLayout
impl Clone for StreamLayout
Source§fn clone(&self) -> StreamLayout
fn clone(&self) -> StreamLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more