Skip to main content

ToolCallBridge

Struct ToolCallBridge 

Source
pub struct ToolCallBridge<I> { /* private fields */ }
Expand description

Per-stream index → grammar-identity map for streamed tool calls.

I is the wire’s own index type (usize for chat-compat chunk indices, i32 for Bedrock content-block indices); it must display so a minted id can derive from it, and order so a drain preserves wire ordering.

Implementations§

Source§

impl<I> ToolCallBridge<I>
where I: Eq + Hash + Ord + Copy,

Source

pub fn new() -> Self

Source

pub fn with_minted_namespace(minted: SyntheticIds) -> Self

A bridge minting slot identities in the given reserved namespace.

Source

pub fn open( &mut self, index: I, wire_id: Option<&str>, name: Option<&str>, ) -> &mut ToolCallSlot

Open (or update) the slot for a wire index, establishing its identity.

On first sight the assembly key is fixed: the wire id when one is supplied, else a freshly minted identity — the single enforcement point of the mandatory-identity invariant. Later fragments update the established provider id and name from any non-empty values they carry.

Source

pub fn get(&self, index: I) -> Option<&ToolCallSlot>

The open slot at a wire index, if any.

Source

pub fn get_mut(&mut self, index: I) -> Option<&mut ToolCallSlot>

The open slot at a wire index, mutably — for fragment bookkeeping on an already-open slot without open’s insert-if-absent.

Source

pub fn minted_ids(&mut self) -> &mut SyntheticIds

The bridge’s identity minter, for adapters that also mint whole-call identities: assemblies and whole calls must draw from ONE counter so their minted keys stay disjoint.

Source

pub fn remove(&mut self, index: I) -> Option<ToolCallSlot>

Close and take the slot at a wire index, if any.

Source

pub fn evict_if( &mut self, index: I, should_evict: impl FnOnce(&ToolCallSlot) -> bool, ) -> Option<ToolCallSlot>

Evict the slot at a wire index when the predicate says the incoming fragment belongs to a different call reusing the same index (the per-profile eviction semantics — e.g. a distinct id + name pair on a wire that restarts indices per call). Returns the evicted slot so the caller can flush it to the consumer.

Source

pub fn decorate(&mut self, decoration: ToolCallDecoration)

Apply a provider decoration to the in-flight call it names, matched by the established provider id. Decorations ride the slot onto its end event; assembly itself is untouched.

Two matching rules keep this deterministic:

  • A slot whose wire never established a provider id (empty id) never matches — a decoration for the empty string would otherwise pick an arbitrary id-less slot out of HashMap iteration order.
  • Each field is first-wins: a later decoration for the same call fills only the fields still unset, so a gemini-style signature-then-params sequence composes instead of the second decoration clobbering the first’s signature with None.
Source

pub fn is_empty(&self) -> bool

Whether any call is still open.

Source

pub fn drain_ordered(&mut self) -> Vec<ToolCallSlot>

Drain every open slot in wire-index order, so a multi-call turn keeps its wire ordering when flushed. The caller chooses the unparseable policy per flush site when building end events.

Source

pub fn drain_ordered_indexed(&mut self) -> Vec<(I, ToolCallSlot)>

ToolCallBridge::drain_ordered, keeping each slot’s wire index — for adapters that track per-slot state of their own beside the bridge (the Responses adapter’s pending call_ids).

Trait Implementations§

Source§

impl<I: Debug> Debug for ToolCallBridge<I>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I> Default for ToolCallBridge<I>
where I: Eq + Hash + Ord + Copy,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<I> Freeze for ToolCallBridge<I>

§

impl<I> RefUnwindSafe for ToolCallBridge<I>
where I: RefUnwindSafe,

§

impl<I> Send for ToolCallBridge<I>
where I: Send,

§

impl<I> Sync for ToolCallBridge<I>
where I: Sync,

§

impl<I> Unpin for ToolCallBridge<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for ToolCallBridge<I>

§

impl<I> UnwindSafe for ToolCallBridge<I>
where I: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more