pub struct T;Expand description
The T namespace — static factory methods for tool composition.
Implementations§
Source§impl T
impl T
Sourcepub fn function(f: Arc<dyn ToolFunction>) -> ToolComposite
pub fn function(f: Arc<dyn ToolFunction>) -> ToolComposite
Register a function tool.
Sourcepub fn google_search() -> ToolComposite
pub fn google_search() -> ToolComposite
Add Google Search built-in tool.
Sourcepub fn url_context() -> ToolComposite
pub fn url_context() -> ToolComposite
Add URL context built-in tool.
Sourcepub fn code_execution() -> ToolComposite
pub fn code_execution() -> ToolComposite
Add code execution built-in tool.
Sourcepub fn simple<F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
f: F,
) -> ToolComposite
pub fn simple<F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
A tool that takes no parameters, from a name, description, and async closure.
The declaration the model sees has no parameters, so the model calls
it with {}. For a tool with arguments, use #[tool]
on a documented async fn, or T::typed when the tool
must capture something (a client, a pool) from its environment.
Sourcepub fn contextual<F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
f: F,
) -> ToolComposite
pub fn contextual<F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
A tool from a closure that also receives the call’s
ToolContext: the session state,
the call id, and a cancellation token that fires on barge-in.
use gemini_adk_fluent_rs::prelude::*;
let balance = T::contextual("balance", "The caller's balance", |_args, ctx| async move {
let account: String = ctx.state.get("account_id").unwrap_or_default();
Ok(serde_json::json!({ "account": account, "cents": 1200 }))
});Sourcepub fn typed<A, F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
f: F,
) -> ToolComposite
pub fn typed<A, F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
A tool whose arguments are the type A, from a closure.
A’s JSON Schema (through wire_schema)
is the declaration, and doc comments on its fields describe the
parameters. Reach for this over #[tool]
when the tool needs state from its environment:
use gemini_adk_fluent_rs::prelude::*;
use std::sync::Arc;
#[derive(serde::Deserialize, schemars::JsonSchema)]
struct Lookup {
/// The customer's account id.
account: String,
}
let accounts = Arc::new(vec![("a-1".to_string(), 120)]);
let balance = T::typed("balance", "Look up an account balance", move |args: Lookup| {
let accounts = accounts.clone();
async move {
let found = accounts.iter().find(|(id, _)| *id == args.account);
Ok(serde_json::json!({ "balance": found.map(|(_, b)| *b) }))
}
});
AgentBuilder::new("support").tools(balance);Sourcepub fn fn_tool<F, Fut>(
name: impl Into<String>,
description: impl Into<String>,
f: F,
) -> ToolComposite
👎Deprecated since 2.1.0: use T::simple (no parameters), T::typed or #[tool]
pub fn fn_tool<F, Fut>( name: impl Into<String>, description: impl Into<String>, f: F, ) -> ToolComposite
use T::simple (no parameters), T::typed or #[tool]
Alias for simple — matches upstream Python T.fn().
Named fn_tool because fn is a reserved keyword in Rust.
Sourcepub fn confirm(tool: impl Into<ToolComposite>, message: &str) -> ToolComposite
pub fn confirm(tool: impl Into<ToolComposite>, message: &str) -> ToolComposite
Require user confirmation before each function tool in the composite runs.
The confirmation flag is recorded on the tool’s ToolPolicy and surfaced
to the runtime via PolicyTool::requires_confirmation — it is never
silently dropped. The message becomes the confirmation hint. Built-in and
placeholder entries are left unchanged.
Sourcepub fn timeout(
tool: impl Into<ToolComposite>,
duration: Duration,
) -> ToolComposite
pub fn timeout( tool: impl Into<ToolComposite>, duration: Duration, ) -> ToolComposite
Bound each function tool in the composite by a timeout.
At dispatch the tool’s future is raced against the duration; on elapse the
call returns ToolError::Timeout.
Built-in and placeholder entries are left unchanged.
Sourcepub fn cached(tool: impl Into<ToolComposite>) -> ToolComposite
pub fn cached(tool: impl Into<ToolComposite>) -> ToolComposite
Memoize each function tool’s successful results.
Results are cached by (tool name, canonical-JSON args); repeat calls with
identical arguments return the cached value without re-invoking the tool.
Errors are not cached. Built-in/placeholder entries are left unchanged.
Sourcepub fn toolset(tools: Vec<Arc<dyn ToolFunction>>) -> ToolComposite
pub fn toolset(tools: Vec<Arc<dyn ToolFunction>>) -> ToolComposite
Combine multiple tool functions into a single composite.
Sourcepub fn agent(
name: impl Into<String>,
description: impl Into<String>,
agent: impl TextAgent + 'static,
) -> ToolComposite
pub fn agent( name: impl Into<String>, description: impl Into<String>, agent: impl TextAgent + 'static, ) -> ToolComposite
Wrap a TextAgent as a tool (shorthand for creating an agent tool entry).
When invoked, the agent runs via BaseLlm::generate() and returns its
text output as the tool result. State is shared with the parent session.
Sourcepub fn mcp(params: impl Into<String>) -> ToolComposite
pub fn mcp(params: impl Into<String>) -> ToolComposite
Create an MCP (Model Context Protocol) toolset entry.
params is the connection string (e.g. a URL or command) used to
establish the MCP session at runtime.
Sourcepub fn mock(
name: impl Into<String>,
description: impl Into<String>,
response: Value,
) -> ToolComposite
pub fn mock( name: impl Into<String>, description: impl Into<String>, response: Value, ) -> ToolComposite
Create a mock tool that returns a fixed response.
Useful for testing and prototyping without real tool implementations.
Sourcepub fn schema(name: impl Into<String>, schema: Value) -> ToolComposite
pub fn schema(name: impl Into<String>, schema: Value) -> ToolComposite
Create a schema-defined tool (placeholder/marker).
The tool’s parameters are defined by the given JSON Schema value.
Sourcepub fn transform<F, Fut>(tool: ToolComposite, f: F) -> ToolComposite
pub fn transform<F, Fut>(tool: ToolComposite, f: F) -> ToolComposite
Wrap each tool entry in a composite with a result transformer.
The transformer function is applied to the tool’s output value before it is returned to the model.
Auto Trait Implementations§
impl Freeze for T
impl RefUnwindSafe for T
impl Send for T
impl Sync for T
impl Unpin for T
impl UnsafeUnpin for T
impl UnwindSafe for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Conv for T
impl<T> Conv for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.