pub struct Kit<M, I = Local, E = Open, T = Unmetered, S = InProcessTasks> { /* private fields */ }Expand description
A module ready to serve, with the seams its calls go through.
Implementations§
Source§impl<M: Module, I: Identity, E: Entitlements, T: Metering, S: TaskStore> Kit<M, I, E, T, S>
impl<M: Module, I: Identity, E: Entitlements, T: Metering, S: TaskStore> Kit<M, I, E, T, S>
pub fn with_entitlements<E2: Entitlements>( self, entitlements: E2, ) -> Kit<M, I, E2, T, S>
pub fn with_metering<T2: Metering>(self, metering: T2) -> Kit<M, I, E, T2, S>
Sourcepub fn with_changes(self, changes: impl ChangeFeed) -> Self
pub fn with_changes(self, changes: impl ChangeFeed) -> Self
Carries resource changes through changes instead of within this
process, for listeners on other instances.
pub fn with_tasks<S2: TaskStore>(self, tasks: S2) -> Kit<M, I, E, T, S2>
pub fn manifest(&self) -> &Manifest
Sourcepub fn tools(&self) -> impl Iterator<Item = &Tool>
pub fn tools(&self) -> impl Iterator<Item = &Tool>
Every registered operation, in registration order.
Sourcepub fn instructions(&self) -> Option<&'static str>
pub fn instructions(&self) -> Option<&'static str>
The module’s guidance for a model, if it gave any.
Sourcepub fn resources(&self) -> impl Iterator<Item = &Resource>
pub fn resources(&self) -> impl Iterator<Item = &Resource>
Every registered resource and resource template.
Sourcepub async fn read(
&self,
uri: &str,
bearer: Option<&str>,
) -> Result<Body, CallError>
pub async fn read( &self, uri: &str, bearer: Option<&str>, ) -> Result<Body, CallError>
Reads the resource at uri for the caller holding bearer.
Sourcepub async fn prompt(
&self,
name: &str,
bearer: Option<&str>,
arguments: JsonObject,
) -> Result<Vec<Message>, CallError>
pub async fn prompt( &self, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<Vec<Message>, CallError>
Fills prompt name from arguments for the caller holding bearer.
Sourcepub async fn call(
&self,
name: &str,
bearer: Option<&str>,
arguments: JsonObject,
) -> Result<Reply, CallError>
pub async fn call( &self, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<Reply, CallError>
Calls operation name for the caller holding bearer, and waits for
its result.
Sourcepub async fn start(
self: &Arc<Self>,
name: &str,
bearer: Option<&str>,
arguments: JsonObject,
) -> Result<StoredTask, CallError>
pub async fn start( self: &Arc<Self>, name: &str, bearer: Option<&str>, arguments: JsonObject, ) -> Result<StoredTask, CallError>
Starts operation name as a task for the caller holding bearer, and
returns it while the operation runs.
Sourcepub async fn update(
self: &Arc<Self>,
bearer: Option<&str>,
id: &str,
answers: BTreeMap<String, Value>,
) -> Result<StoredTask, CallError>
pub async fn update( self: &Arc<Self>, bearer: Option<&str>, id: &str, answers: BTreeMap<String, Value>, ) -> Result<StoredTask, CallError>
Gives a task that asked for input the user’s answers and runs its
operation again with them. A task not waiting for input is left as
it is, as are answers to questions it did not ask.
Sourcepub async fn task(
&self,
bearer: Option<&str>,
id: &str,
) -> Result<StoredTask, CallError>
pub async fn task( &self, bearer: Option<&str>, id: &str, ) -> Result<StoredTask, CallError>
The caller’s task id.
Sourcepub async fn cancel(
&self,
bearer: Option<&str>,
id: &str,
) -> Result<StoredTask, CallError>
pub async fn cancel( &self, bearer: Option<&str>, id: &str, ) -> Result<StoredTask, CallError>
Marks the caller’s task id cancelled. Cooperative: the operation
sees Ctx::is_cancelled when it runs in this process, stops where
its state is whole, and its result is discarded; the kit never stops
it between two awaits.