pub struct FragmentRegistry { /* private fields */ }Expand description
A registry of discovered fragments supporting progressive disclosure, argument expansion, and prompt/RPC metadata formatting.
Implementations§
Source§impl FragmentRegistry
impl FragmentRegistry
Sourcepub fn from_resources(resources: Vec<FragmentResource>) -> Self
pub fn from_resources(resources: Vec<FragmentResource>) -> Self
Build a registry from discovered fragment resources.
Sourcepub fn get(&self, name: &str) -> Option<&FragmentResource>
pub fn get(&self, name: &str) -> Option<&FragmentResource>
Look up a fragment by name, returning its resource (metadata only).
Sourcepub fn load_body(
&self,
name: &str,
) -> Option<Result<String, FragmentDiscoveryError>>
pub fn load_body( &self, name: &str, ) -> Option<Result<String, FragmentDiscoveryError>>
Load the full body of a fragment by name.
Returns None if the fragment is not found or Some(Err(...)) if the
file cannot be read.
Sourcepub fn expand(
&self,
name: &str,
values: &HashMap<String, String>,
) -> Option<Result<String, FragmentDiscoveryError>>
pub fn expand( &self, name: &str, values: &HashMap<String, String>, ) -> Option<Result<String, FragmentDiscoveryError>>
Expand a fragment by name with the provided argument values.
Loads the body on demand, validates arguments, and performs placeholder
substitution. Returns None if the fragment is not found.
Sourcepub fn format_for_prompt(&self) -> String
pub fn format_for_prompt(&self) -> String
Format all fragment metadata as a string suitable for inclusion in a system prompt or command listing.
Each fragment is represented as a brief entry with name, description, and argument summary.
Sourcepub fn format_for_rpc_metadata(&self) -> String
pub fn format_for_rpc_metadata(&self) -> String
Format all fragment metadata as a string suitable for RPC command metadata listing.
Includes argument names, required/optional status, and default values.
Auto Trait Implementations§
impl Freeze for FragmentRegistry
impl RefUnwindSafe for FragmentRegistry
impl Send for FragmentRegistry
impl Sync for FragmentRegistry
impl Unpin for FragmentRegistry
impl UnsafeUnpin for FragmentRegistry
impl UnwindSafe for FragmentRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more