Skip to main content

AgentSink

Trait AgentSink 

Source
pub trait AgentSink: Send + Sync {
    // Provided methods
    fn step<'a>(
        &'a self,
        _step: &'a AgentStep,
        _credits: u64,
    ) -> BoxFuture<'a, ()> { ... }
    fn cancelled(&self) -> bool { ... }
    fn reserve_page<'a>(
        &'a self,
        _url: &'a str,
    ) -> BoxFuture<'a, Result<(), ApiError>> { ... }
    fn charge_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()> { ... }
    fn release_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()> { ... }
    fn pages_left(&self) -> Option<u64> { ... }
}
Expand description

agent 运行的回报和额度,由 API 层的任务管理实现;() 是不回报、不限额的实现。

Provided Methods§

Source

fn step<'a>(&'a self, _step: &'a AgentStep, _credits: u64) -> BoxFuture<'a, ()>

一次工具调用结束;credits 是到现在为止用掉的额度。

Source

fn cancelled(&self) -> bool

调用方要求取消:在两步之间生效。

Source

fn reserve_page<'a>( &'a self, _url: &'a str, ) -> BoxFuture<'a, Result<(), ApiError>>

发出一次页面抓取之前调用:原子预留这一页的配额;拒绝时不得发请求。

Source

fn charge_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>

这一页抓回并会交付:结算预留。

Source

fn release_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>

这一页失败或没有交付:退还预留。

Source

fn pages_left(&self) -> Option<u64>

调用方今天还能抓多少页;没有配额时 None。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AgentSink for ()

Implementors§