Skip to main content

RealtimePeer

Struct RealtimePeer 

Source
pub struct RealtimePeer { /* private fields */ }
Expand description

A running stand-in peer.

Dropping it cancels the listener and every session it is serving; there is no way to leave one running past the end of a test, which is what keeps a suite’s ports and tasks bounded.

Implementations§

Source§

impl RealtimePeer

Source

pub fn url(&self) -> &str

The URL a client connects to, without the ?model= the client is expected to add.

Source

pub fn addr(&self) -> SocketAddr

The loopback address the peer is listening on.

Source

pub fn record(&self) -> Record

A snapshot of everything observed so far.

Source

pub async fn observe<F>( &self, what: &str, condition: F, ) -> Result<Record, PeerError>
where F: Fn(&Record) -> bool,

Wait until the record satisfies condition, and return it.

The wait completes on the record changing, never on a clock; what names the observation so a peer that never produces it fails with a sentence rather than with a hang.

Source

pub async fn await_upgrade(&self) -> Result<Record, PeerError>

Wait until at least one upgrade has been answered, either way.

Source

pub async fn await_session_update(&self) -> Result<Record, PeerError>

Wait until the client’s session.update has been read.

Source

pub async fn await_appends(&self, count: usize) -> Result<Record, PeerError>

Wait until count uplink frames have been appended.

Source

pub async fn await_cancel(&self) -> Result<Record, PeerError>

Wait until the client has cancelled a response.

Source

pub async fn send_delta( &self, response: &str, audio: &[u8], ) -> Result<Emission, PeerError>

Send one response.output_audio.delta carrying these bytes, base64 per RFC 4648 §4.

Source

pub async fn speak_tone( &self, response: &str, frames: usize, ) -> Result<usize, PeerError>

Speak frames frames of the tone as one delta each, stopping at the first one the peer suppresses. Returns how many reached the socket.

Source

pub async fn send_audio_done( &self, response: &str, ) -> Result<Emission, PeerError>

Send response.output_audio.done, which is where §4.1’s partial-frame padding happens.

Source

pub async fn send_response_done( &self, response: &str, status: &str, ) -> Result<Emission, PeerError>

Send response.done with this status, ending any cancel-race window (§4.3).

Source

pub async fn send_speech_started(&self) -> Result<Emission, PeerError>

Send input_audio_buffer.speech_started, the barge-in trigger of §4.3.

Source

pub async fn send_error( &self, code: &str, message: &str, ) -> Result<Emission, PeerError>

Send an error event (§5.2), which is either the cancel race or session-fatal.

Source

pub async fn send_unknown( &self, event_type: &str, ) -> Result<Emission, PeerError>

Send an event outside §5.2 — what ORB-12 requires be ignored with a counter.

Source

pub async fn send_malformed( &self, malformed: Malformed, ) -> Result<Emission, PeerError>

Send a frame that cannot be read as an event (§5.3).

Source

pub async fn send_oversize(&self, bytes: usize) -> Result<Emission, PeerError>

Send one text frame of at least bytes bytes — §5.3’s 1 MiB bound is 1 048 576 (ORB-11).

Source

pub async fn close_normally(&self) -> Result<Emission, PeerError>

Close the connection with 1000, the way a well-behaved far end ends a session (ORB-16).

Source

pub async fn reset(&self) -> Result<Emission, PeerError>

Reset the connection: no close frame, no close handshake (ORB-16’s second half).

Source

pub async fn shutdown(self)

Stop serving and join every task the peer owns.

Dropping the peer does the same thing without the join; this exists for a test that wants to prove there is no orphan left behind.

Trait Implementations§

Source§

impl Debug for RealtimePeer

Source§

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

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

impl Drop for RealtimePeer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

§

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