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
impl RealtimePeer
Sourcepub fn url(&self) -> &str
pub fn url(&self) -> &str
The URL a client connects to, without the ?model= the client is expected to add.
Sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
The loopback address the peer is listening on.
Sourcepub async fn observe<F>(
&self,
what: &str,
condition: F,
) -> Result<Record, PeerError>
pub async fn observe<F>( &self, what: &str, condition: F, ) -> Result<Record, PeerError>
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.
Sourcepub async fn await_upgrade(&self) -> Result<Record, PeerError>
pub async fn await_upgrade(&self) -> Result<Record, PeerError>
Wait until at least one upgrade has been answered, either way.
Sourcepub async fn await_session_update(&self) -> Result<Record, PeerError>
pub async fn await_session_update(&self) -> Result<Record, PeerError>
Wait until the client’s session.update has been read.
Sourcepub async fn await_appends(&self, count: usize) -> Result<Record, PeerError>
pub async fn await_appends(&self, count: usize) -> Result<Record, PeerError>
Wait until count uplink frames have been appended.
Sourcepub async fn await_cancel(&self) -> Result<Record, PeerError>
pub async fn await_cancel(&self) -> Result<Record, PeerError>
Wait until the client has cancelled a response.
Sourcepub async fn send_delta(
&self,
response: &str,
audio: &[u8],
) -> Result<Emission, PeerError>
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.
Sourcepub async fn speak_tone(
&self,
response: &str,
frames: usize,
) -> Result<usize, PeerError>
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.
Sourcepub async fn send_audio_done(
&self,
response: &str,
) -> Result<Emission, PeerError>
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.
Sourcepub async fn send_response_done(
&self,
response: &str,
status: &str,
) -> Result<Emission, PeerError>
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).
Sourcepub async fn send_speech_started(&self) -> Result<Emission, PeerError>
pub async fn send_speech_started(&self) -> Result<Emission, PeerError>
Send input_audio_buffer.speech_started, the barge-in trigger of §4.3.
Sourcepub async fn send_error(
&self,
code: &str,
message: &str,
) -> Result<Emission, PeerError>
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.
Sourcepub async fn send_unknown(
&self,
event_type: &str,
) -> Result<Emission, PeerError>
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.
Sourcepub async fn send_malformed(
&self,
malformed: Malformed,
) -> Result<Emission, PeerError>
pub async fn send_malformed( &self, malformed: Malformed, ) -> Result<Emission, PeerError>
Send a frame that cannot be read as an event (§5.3).
Sourcepub async fn send_oversize(&self, bytes: usize) -> Result<Emission, PeerError>
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).
Sourcepub async fn close_normally(&self) -> Result<Emission, PeerError>
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).
Trait Implementations§
Source§impl Debug for RealtimePeer
impl Debug for RealtimePeer
Source§impl Drop for RealtimePeer
impl Drop for RealtimePeer
Auto Trait Implementations§
impl Freeze for RealtimePeer
impl RefUnwindSafe for RealtimePeer
impl Send for RealtimePeer
impl Sync for RealtimePeer
impl Unpin for RealtimePeer
impl UnsafeUnpin for RealtimePeer
impl UnwindSafe for RealtimePeer
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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