Skip to main content

Hat

Struct Hat 

Source
pub struct Hat {
    pub id: HatId,
    pub name: String,
    pub description: String,
    pub subscriptions: Vec<Topic>,
    pub publishes: Vec<Topic>,
    pub instructions: String,
}
Expand description

A hat (persona) that defines agent behavior.

Fields§

§id: HatId

Unique identifier for this hat.

§name: String

Human-readable name for the hat.

§description: String

Short description of the hat’s purpose. Used in the HATS table to help Ralph understand when to delegate.

§subscriptions: Vec<Topic>

Topic patterns this hat subscribes to.

§publishes: Vec<Topic>

Topics this hat is expected to publish.

§instructions: String

Instructions prepended to prompts for this hat.

Implementations§

Source§

impl Hat

Source

pub fn new(id: impl Into<HatId>, name: impl Into<String>) -> Self

Creates a new hat with the given ID and name.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Sets the description for this hat.

Source

pub fn default_single() -> Self

👎Deprecated:

Use default_planner() and default_builder() instead

Creates the default hat for single-hat mode.

Source

pub fn default_planner() -> Self

Creates the default planner hat.

Per spec: Planner triggers on task.start, task.resume, build.done, build.blocked and publishes build.task.

Source

pub fn default_builder() -> Self

Creates the default builder hat.

Per spec: Builder triggers on build.task and publishes build.done or build.blocked.

Source

pub fn subscribe(self, topic: impl Into<Topic>) -> Self

Adds a subscription to this hat.

Source

pub fn with_instructions(self, instructions: impl Into<String>) -> Self

Sets the instructions for this hat.

Source

pub fn with_publishes(self, publishes: Vec<Topic>) -> Self

Sets the topics this hat publishes.

Source

pub fn is_subscribed(&self, topic: &Topic) -> bool

Checks if this hat is subscribed to the given topic.

Source

pub fn is_subscribed_str(&self, topic: &str) -> bool

Checks if this hat is subscribed to the given topic string.

Zero-allocation variant of is_subscribed() for hot paths.

Source

pub fn has_specific_subscription(&self, topic: &Topic) -> bool

Checks if this hat has a specific (non-global-wildcard) subscription for the topic.

Returns true if the hat matches via a specific pattern (e.g., task.*, build.done) rather than a global wildcard *. Used for routing priority - specific subscriptions take precedence over fallback wildcards.

Source

pub fn is_fallback_only(&self) -> bool

Returns true if all subscriptions are global wildcards (*).

Used to identify fallback handlers like Ralph.

Trait Implementations§

Source§

impl Clone for Hat

Source§

fn clone(&self) -> Hat

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 Hat

Source§

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

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

impl<'de> Deserialize<'de> for Hat

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 Serialize for Hat

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

Auto Trait Implementations§

§

impl Freeze for Hat

§

impl RefUnwindSafe for Hat

§

impl Send for Hat

§

impl Sync for Hat

§

impl Unpin for Hat

§

impl UnsafeUnpin for Hat

§

impl UnwindSafe for Hat

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, 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>,