Skip to main content

ShellLedger

Trait ShellLedger 

Source
pub trait ShellLedger:
    Debug
    + Send
    + Sync {
    // Required methods
    fn record<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        app: &'life1 str,
        user: &'life2 str,
        session: &'life3 str,
        entry: ShellLedgerEntry,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn get<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        app: &'life1 str,
        user: &'life2 str,
        session: &'life3 str,
        function_call_id: &'life4 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ShellLedgerEntry>, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             Self: 'async_trait;
    fn mark_retried<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        app: &'life1 str,
        user: &'life2 str,
        session: &'life3 str,
        function_call_id: &'life4 str,
        by: &'life5 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait,
             Self: 'async_trait;
}
Available on crate feature harness only.
Expand description

Where the harness records each session’s bash calls (spec 3.1 §7.9).

An unsandboxed retry is authorized only against a failed sandboxed call recorded here, and mark_retried lets exactly one retry consume it (spec 3.1 §9.2 I25).

§Example

use adk_harness::{InMemoryShellLedger, ShellLedger, ShellLedgerEntry};

let ledger = InMemoryShellLedger::new();
ledger.record("app", "u", "s", ShellLedgerEntry::new("c1", "make", true, Some(2))).await?;
assert!(ledger.mark_retried("app", "u", "s", "c1", "c2").await?);
assert!(!ledger.mark_retried("app", "u", "s", "c1", "c3").await?);

Required Methods§

Source

fn record<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, app: &'life1 str, user: &'life2 str, session: &'life3 str, entry: ShellLedgerEntry, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Records a finished call, replacing an earlier entry with the same call ID.

Source

fn get<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, app: &'life1 str, user: &'life2 str, session: &'life3 str, function_call_id: &'life4 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ShellLedgerEntry>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

The entry for function_call_id, if recorded.

Source

fn mark_retried<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, app: &'life1 str, user: &'life2 str, session: &'life3 str, function_call_id: &'life4 str, by: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<bool, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait, Self: 'async_trait,

Marks the entry as retried by by. Returns true only for the first retry of a recorded entry.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§