Skip to main content

ComponentId

Struct ComponentId 

Source
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 FQN

Fields§

§uuid: Uuid

Globally unique identifier.

§namespace: String

Namespace (e.g., “builtin”, “plugin”, “wasm”).

§name: String

Component name within namespace.

Implementations§

Source§

impl ComponentId

Source

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");
Source

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());
Source

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");
Source

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 FQN
Source

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"));
Source

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());
Source

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");
Source

pub fn is_child(&self) -> bool

Returns true if this is a child component.

Trait Implementations§

Source§

impl Clone for ComponentId

Source§

fn clone(&self) -> ComponentId

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ComponentId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ComponentId

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ComponentId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ComponentId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ComponentId

Source§

fn eq(&self, other: &ComponentId) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ComponentId

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for ComponentId

Source§

impl StructuralPartialEq for ComponentId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,