Skip to main content

Registration

Struct Registration 

Source
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

Source

pub fn client<E, M>( descriptor: Descriptor, executor: Arc<E>, mapper: Arc<M>, ) -> Self
where E: Executor, M: Fn(E::Output) -> Result<ToolResult, MappingError> + Send + Sync + 'static,

Statically pairs a client executor output with its only mapper.

Source

pub fn hosted(descriptor: Descriptor, extension: Envelope) -> Self

Creates a model-native registration with an owned provider extension and no local dispatcher.

Source

pub const fn descriptor(&self) -> &Descriptor

Returns the owned model descriptor.

Source

pub const fn lane(&self) -> Lane

Returns the immutable execution lane.

Trait Implementations§

Source§

impl Clone for Registration

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Registration

Source§

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

Shows what was registered and whether a local dispatcher backs it.

The executor is a trait object with no Debug, and its presence is the fact that matters anyway: it is exactly what makes this a client lane rather than a hosted one.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.