pub trait CardHints: Send + Sync {
// Required method
fn hint<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<CardHint>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn names<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
A feature’s hints for the decisions its tools ask (spec 3.3 §7.1), read by the engine wherever it draws a card.
Return None for every request that is not the feature’s own, told by
ApprovalRequest::origin. Read only request and the feature’s own kernel-side data,
never text an agent wrote; a failure to read that data is logged and answered with None
or a hint that says less, since the card is shown either way.
§Example
use std::sync::Arc;
use adk_core::ApprovalRequest;
use adk_surface::{CardHint, CardHints, LocalSource, Reversibility, SurfaceEngine};
/// The cards of tools published as `verbs:adk-rust`.
struct Verbs;
#[async_trait::async_trait]
impl CardHints for Verbs {
async fn hint(&self, request: &ApprovalRequest) -> Option<CardHint> {
let origin = request.origin.as_ref()?;
(origin.source == "verbs:adk-rust").then(|| {
CardHint::new()
.with_chat_heading("Snooze something in Coming up")
.with_reversibility(Reversibility::CanBeChangedBack)
.without_always_allow()
})
}
}
let engine = SurfaceEngine::builder(Arc::new(source)).card_hints(Arc::new(Verbs)).build();Required Methods§
Provided Methods§
Sourcefn names<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn names<'life0, 'life1, 'async_trait>(
&'life0 self,
_request: &'life1 ApprovalRequest,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
What request’s call acts on, as the person knows it — “News digest” — which the
record of an answer to it names beside the card’s summary (spec 3.3 §8, §11). None,
the default, for a call that names nothing a person knows or that is not this
feature’s.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".