use everruns_contracts::typed_id::SessionId;
use crate::host::events::{EventCursor, EventLogError};
impl EventCursor {
pub fn after_snapshot(
session_id: SessionId,
after_sequence: i32,
snapshot_high_watermark: i32,
) -> Result<Self, EventLogError> {
if after_sequence < 0 || snapshot_high_watermark < after_sequence {
return Err(EventLogError::InvalidRead {
detail: "cursor position must be within [0, snapshot high-watermark]".into(),
});
}
Ok(Self {
session_id,
after_sequence,
snapshot_high_watermark: Some(snapshot_high_watermark),
})
}
}