pub struct FakeTransport {
state: Arc<Mutex<State>>,
clock: Option<TestClock>,
}Expand description
Cloneable handle: clones share one script and one call log.
Fields§
§state: Arc<Mutex<State>>§clock: Option<TestClock>Implementations§
Source§impl FakeTransport
impl FakeTransport
pub fn new() -> Self
pub fn with_clock(self, clock: TestClock) -> Self
fn now(&self) -> i64
pub fn on(&self, op_id: &str, responses: Vec<Result<Value, TransportError>>)
Sourcepub fn on_matching(
&self,
op_id: &str,
params_subset: &[(&str, &str)],
responses: Vec<Result<Value, TransportError>>,
)
pub fn on_matching( &self, op_id: &str, params_subset: &[(&str, &str)], responses: Vec<Result<Value, TransportError>>, )
Consumed in order, the last repeats; the script with the largest matching subset wins.
pub fn on_wait(&self, script: Vec<(Result<WaitOutcome, TransportError>, u64)>)
pub fn on_lifecycle( &self, verb: Lifecycle, result: Result<String, TransportError>, )
Sourcepub fn on_lifecycle_seq(
&self,
verb: Lifecycle,
results: Vec<Result<String, TransportError>>,
)
pub fn on_lifecycle_seq( &self, verb: Lifecycle, results: Vec<Result<String, TransportError>>, )
Answers for verb in order, one per call; once used up, on_lifecycle’s answer (or the default).
pub fn on_cli_version(&self, result: Result<String, TransportError>)
pub fn set_openapi(&self, doc: Option<Value>)
pub fn calls(&self) -> Vec<RecordedCall>
pub fn wait_calls(&self) -> Vec<(String, u64, i64)>
pub fn lifecycle_calls(&self) -> Vec<(Lifecycle, i64)>
pub fn openapi_fetches(&self) -> usize
Trait Implementations§
Source§impl Clone for FakeTransport
impl Clone for FakeTransport
Source§fn clone(&self) -> FakeTransport
fn clone(&self) -> FakeTransport
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for FakeTransport
impl Default for FakeTransport
Source§impl Transport for FakeTransport
impl Transport for FakeTransport
async fn call( &self, op: &Operation, params: &Params, body: Option<&Value>, _deadline: Duration, ) -> Result<Value, TransportError>
async fn lifecycle(&self, verb: Lifecycle) -> Result<String, TransportError>
async fn wait_idle( &self, session_id: &str, deadline: Duration, ) -> Result<WaitOutcome, TransportError>
async fn fetch_openapi(&self) -> Result<Value, TransportError>
Source§async fn cli_version(&self) -> Result<String, TransportError>
async fn cli_version(&self) -> Result<String, TransportError>
Raw
opencode --version stdout, trimmed, e.g. opencode v2.0.32.Auto Trait Implementations§
impl Freeze for FakeTransport
impl RefUnwindSafe for FakeTransport
impl Send for FakeTransport
impl Sync for FakeTransport
impl Unpin for FakeTransport
impl UnsafeUnpin for FakeTransport
impl UnwindSafe for FakeTransport
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
Mutably borrows from an owned value. Read more