pub struct Registration { /* private fields */ }Expand description
One fully owned registration, suitable for static or dynamic providers.
A registration is one entry in a Registry: what the model is told about a
tool (Descriptor) and who runs it. The latter is the choice between the
two constructors, and it is the whole of the Lane distinction —
Registration::client pairs an Executor with its mapper and reef
dispatches the call itself, while Registration::hosted declares a
capability the provider executes and carries the opaque envelope that
configures it.
use reef_core::opaque;
use reef_core::runtime::tool;
let hosted = tool::Registration::hosted(
tool::Descriptor::new(
tool::Name::local("web.search".to_owned()).unwrap(),
"Provider-run web search".to_owned(),
opaque::Payload::copy_from_slice(b"{}"),
),
// Uninterpreted by reef, and passed to the provider unchanged.
opaque::Envelope::try_new(
"example.provider".to_owned(),
"web_search".to_owned(),
opaque::Payload::copy_from_slice(br#"{"max_results":5}"#),
)
.unwrap(),
);
assert_eq!(hosted.lane(), tool::Lane::Hosted);
let mut registry = tool::RegistryBuilder::new();
registry.register(hosted);
// Names are canonical and collisions fail closed, before any side effect.
assert!(registry.build().is_ok());Executor carries the client-lane example.
Implementations§
Source§impl Registration
impl Registration
Sourcepub fn client<E, M>(
descriptor: Descriptor,
executor: Arc<E>,
mapper: Arc<M>,
) -> Self
pub fn client<E, M>( descriptor: Descriptor, executor: Arc<E>, mapper: Arc<M>, ) -> Self
Statically pairs a client executor output with its only mapper.
Sourcepub fn hosted(descriptor: Descriptor, extension: Envelope) -> Self
pub fn hosted(descriptor: Descriptor, extension: Envelope) -> Self
Creates a model-native registration with an owned provider extension and no local dispatcher.
Sourcepub const fn descriptor(&self) -> &Descriptor
pub const fn descriptor(&self) -> &Descriptor
Returns the owned model descriptor.
Trait Implementations§
Source§impl Clone for Registration
impl Clone for Registration
Source§impl Debug for Registration
impl Debug for Registration
Auto Trait Implementations§
impl !RefUnwindSafe for Registration
impl !UnwindSafe for Registration
impl Freeze for Registration
impl Send for Registration
impl Sync for Registration
impl Unpin for Registration
impl UnsafeUnpin for Registration
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
Mutably borrows from an owned value. Read more