pub struct ResourceStateManager { /* private fields */ }Expand description
Thread-safe registry of collaborative document resources.
ResourceStateManager maintains the canonical state for all active resources in the
system. It provides methods for creating resources, applying edits, and querying state.
All operations are atomic and thread-safe.
Implementations§
Source§impl ResourceStateManager
impl ResourceStateManager
Sourcepub fn get_or_create_resource(
&self,
resource_id: &str,
initial_agent_id: &str,
requested_merge_type: Option<&str>,
) -> Arc<Mutex<ResourceState>> ⓘ
pub fn get_or_create_resource( &self, resource_id: &str, initial_agent_id: &str, requested_merge_type: Option<&str>, ) -> Arc<Mutex<ResourceState>> ⓘ
Get or create a resource, initializing its CRDT if needed.
Sourcepub fn subscribe_to_indices(&self) -> Receiver<String>
pub fn subscribe_to_indices(&self) -> Receiver<String>
Subscribe to new resource creation events.
Sourcepub fn get_resource(
&self,
resource_id: &str,
) -> Option<Arc<Mutex<ResourceState>>>
pub fn get_resource( &self, resource_id: &str, ) -> Option<Arc<Mutex<ResourceState>>>
Get an existing resource without creating it.
Sourcepub fn list_resources(&self) -> Vec<String>
pub fn list_resources(&self) -> Vec<String>
List all resource IDs currently in memory.
Sourcepub fn has_version(&self, resource_id: &str, version_id: &str) -> bool
pub fn has_version(&self, resource_id: &str, version_id: &str) -> bool
Check if a resource has already seen a specific version.
Sourcepub fn apply_update(
&self,
resource_id: &str,
content: &str,
agent_id: &str,
version_id: Option<&str>,
requested_merge_type: Option<&str>,
) -> Result<Value, String>
pub fn apply_update( &self, resource_id: &str, content: &str, agent_id: &str, version_id: Option<&str>, requested_merge_type: Option<&str>, ) -> Result<Value, String>
Apply a full document update (replacement).
Sourcepub fn apply_remote_insert(
&self,
resource_id: &str,
agent_id: &str,
pos: usize,
text: &str,
version_id: Option<&str>,
requested_merge_type: Option<&str>,
) -> Result<Value, String>
pub fn apply_remote_insert( &self, resource_id: &str, agent_id: &str, pos: usize, text: &str, version_id: Option<&str>, requested_merge_type: Option<&str>, ) -> Result<Value, String>
Apply a remote insertion operation.
Sourcepub fn apply_remote_insert_versioned(
&self,
resource_id: &str,
agent_id: &str,
parents: &[&str],
pos: usize,
text: &str,
version_id: Option<&str>,
requested_merge_type: Option<&str>,
) -> Result<Value, String>
pub fn apply_remote_insert_versioned( &self, resource_id: &str, agent_id: &str, parents: &[&str], pos: usize, text: &str, version_id: Option<&str>, requested_merge_type: Option<&str>, ) -> Result<Value, String>
Apply a remote insertion operation at a specific version.
Sourcepub fn apply_remote_delete(
&self,
resource_id: &str,
agent_id: &str,
start: usize,
end: usize,
version_id: Option<&str>,
requested_merge_type: Option<&str>,
) -> Result<Value, String>
pub fn apply_remote_delete( &self, resource_id: &str, agent_id: &str, start: usize, end: usize, version_id: Option<&str>, requested_merge_type: Option<&str>, ) -> Result<Value, String>
Apply a remote deletion operation.
Sourcepub fn apply_remote_delete_versioned(
&self,
resource_id: &str,
agent_id: &str,
parents: &[&str],
range: Range<usize>,
version_id: Option<&str>,
requested_merge_type: Option<&str>,
) -> Result<Value, String>
pub fn apply_remote_delete_versioned( &self, resource_id: &str, agent_id: &str, parents: &[&str], range: Range<usize>, version_id: Option<&str>, requested_merge_type: Option<&str>, ) -> Result<Value, String>
Apply a remote deletion operation at a specific version.
Sourcepub fn get_resource_state(&self, resource_id: &str) -> Option<Value>
pub fn get_resource_state(&self, resource_id: &str) -> Option<Value>
Get a snapshot of a resource’s current state.
Sourcepub fn get_merge_quality(&self, resource_id: &str) -> Option<u32>
pub fn get_merge_quality(&self, resource_id: &str) -> Option<u32>
Get the merge quality score for a resource.
Sourcepub fn register_version_mapping(
&self,
resource_id: &str,
version: String,
frontier: Frontier,
)
pub fn register_version_mapping( &self, resource_id: &str, version: String, frontier: Frontier, )
Register a version mapping for a resource.
Sourcepub fn get_history(
&self,
resource_id: &str,
since_versions: &[&str],
) -> Result<Vec<SerializedOpsOwned>, String>
pub fn get_history( &self, resource_id: &str, since_versions: &[&str], ) -> Result<Vec<SerializedOpsOwned>, String>
Get history for a resource since a set of versions.