pub struct ComponentId {
pub uuid: Uuid,
pub namespace: String,
pub name: String,
}Expand description
Identifier for a Component in the ORCS architecture.
A Component is a functional domain boundary that communicates via the EventBus. Examples include:
builtin::llm- LLM integration (chat, complete, embed)builtin::tool- Tool execution (read, write, bash)builtin::hil- Human-in-the-loop (approve, reject)plugin::my-tool- User-defined extensions
§UUID Strategy
- Builtin components: Use UUID v5 (deterministic from name)
- Custom components: Use UUID v4 (random)
This ensures builtin components have consistent UUIDs across processes and machines, enabling reliable routing and comparison.
§Equality Semantics
PartialEq compares all fields including UUID. For FQN-only
comparison (ignoring UUID), use fqn_eq.
§Example
use orcs_types::ComponentId;
// Builtin: deterministic UUID
let llm1 = ComponentId::builtin("llm");
let llm2 = ComponentId::builtin("llm");
assert_eq!(llm1, llm2); // Same UUID, same component
// Custom: random UUID per instance
let p1 = ComponentId::new("plugin", "tool");
let p2 = ComponentId::new("plugin", "tool");
assert_ne!(p1, p2); // Different UUIDs
assert!(p1.fqn_eq(&p2)); // But same FQNFields§
§uuid: UuidGlobally unique identifier.
namespace: StringNamespace (e.g., “builtin”, “plugin”, “wasm”).
name: StringComponent name within namespace.
Implementations§
Source§impl ComponentId
impl ComponentId
Sourcepub fn new(namespace: impl Into<String>, name: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>, name: impl Into<String>) -> Self
Creates a new ComponentId with a random UUID v4.
Use this for custom/plugin components where each instance should have a unique identity.
§Example
use orcs_types::ComponentId;
let plugin = ComponentId::new("plugin", "my-tool");
assert_eq!(plugin.namespace, "plugin");
assert_eq!(plugin.name, "my-tool");
assert_eq!(plugin.fqn(), "plugin::my-tool");Sourcepub fn builtin(name: impl Into<String>) -> Self
pub fn builtin(name: impl Into<String>) -> Self
Creates a builtin component ID with a deterministic UUID v5.
The UUID is derived from the ORCS namespace UUID and the component name using SHA-1. This ensures:
- Same name always produces same UUID
- Different names produce different UUIDs
- UUIDs are consistent across processes/machines
§Example
use orcs_types::ComponentId;
let llm1 = ComponentId::builtin("llm");
let llm2 = ComponentId::builtin("llm");
let tool = ComponentId::builtin("tool");
assert_eq!(llm1.uuid, llm2.uuid); // Same name = same UUID
assert_ne!(llm1.uuid, tool.uuid); // Different name = different UUID
assert!(llm1.is_builtin());Sourcepub fn fqn(&self) -> String
pub fn fqn(&self) -> String
Returns the fully qualified name in namespace::name format.
§Example
use orcs_types::ComponentId;
let id = ComponentId::builtin("llm");
assert_eq!(id.fqn(), "builtin::llm");Sourcepub fn fqn_eq(&self, other: &Self) -> bool
pub fn fqn_eq(&self, other: &Self) -> bool
Compares two ComponentIds by FQN only, ignoring UUID.
This is useful when you want to check if two components represent the same logical component, even if they were created as separate instances.
§Example
use orcs_types::ComponentId;
let p1 = ComponentId::new("plugin", "tool");
let p2 = ComponentId::new("plugin", "tool");
assert_ne!(p1, p2); // Different UUIDs
assert!(p1.fqn_eq(&p2)); // Same FQNSourcepub fn matches(&self, namespace: &str, name: &str) -> bool
pub fn matches(&self, namespace: &str, name: &str) -> bool
Checks if this component matches the given namespace and name.
§Example
use orcs_types::ComponentId;
let llm = ComponentId::builtin("llm");
assert!(llm.matches("builtin", "llm"));
assert!(!llm.matches("builtin", "tool"));Sourcepub fn is_builtin(&self) -> bool
pub fn is_builtin(&self) -> bool
Returns true if this is a builtin component.
§Example
use orcs_types::ComponentId;
let builtin = ComponentId::builtin("llm");
let plugin = ComponentId::new("plugin", "tool");
assert!(builtin.is_builtin());
assert!(!plugin.is_builtin());Sourcepub fn child(name: impl Into<String>) -> Self
pub fn child(name: impl Into<String>) -> Self
Creates a child component ID with a deterministic UUID v5.
The UUID is derived from the ORCS namespace UUID and the child name using SHA-1.
§Example
use orcs_types::ComponentId;
let child = ComponentId::child("worker-1");
assert_eq!(child.namespace, "child");
assert_eq!(child.name, "worker-1");Trait Implementations§
Source§impl Clone for ComponentId
impl Clone for ComponentId
Source§fn clone(&self) -> ComponentId
fn clone(&self) -> ComponentId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more