Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event<'a> { Panicked { method: &'a str, message: &'a str, }, Invalid { error: &'a ErrorObject, answered: bool, }, UnknownNotification { method: &'a str, }, Dropped { method: &'a str, }, Unmatched { id: &'a Id<'a>, }, PeerError { error: &'a ErrorObject, }, Oversized { error: FrameError, }, Cancelled { id: &'a Id<'a>, }, }
Available on crate feature std only.
Expand description

Something the endpoint handled on its own, reported to Router::on_event so an application can log it.

§Examples

use rpc_io::Event;

fn describe(event: &Event<'_>) -> String {
    match event {
        Event::Panicked { method, message } => format!("`{method}` panicked: {message}"),
        other => format!("{other:?}"),
    }
}
assert_eq!(describe(&Event::Panicked { method: "m", message: "boom" }), "`m` panicked: boom");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Panicked

A handler panicked. A request was answered with INTERNAL_ERROR (without the panic message, which may hold details the peer should not see); the message is here.

Fields

§method: &'a str

The method whose handler panicked.

§message: &'a str

The panic message, clipped, or a placeholder.

§

Invalid

A malformed message arrived: answered with error if it was request-like, dropped if it was a malformed response to one of our requests (which then ends with CallError::InvalidResponse).

Fields

§error: &'a ErrorObject

What was wrong.

§answered: bool

Whether it was answered.

§

UnknownNotification

A notification for a method with no notification handler.

Fields

§method: &'a str

The method.

§

Dropped

A notification dropped because it arrived before the Gate opened.

Fields

§method: &'a str

The method.

§

Unmatched

A response whose id matches none of our outstanding requests (late, repeated, or forged).

Fields

§id: &'a Id<'a>

The id it carried.

§

PeerError

An error response with a null id: the peer could not read something we sent.

Fields

§error: &'a ErrorObject

The peer’s error.

§

Oversized

A message over Limits::max_message_bytes was skipped unread, and answered with INVALID_REQUEST under a null id.

Fields

§error: FrameError

The framing error with the sizes.

§

Cancelled

The peer cancelled one of its requests that was in flight.

Fields

§id: &'a Id<'a>

The cancelled request’s id.

Trait Implementations§

Source§

impl<'a> Clone for Event<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Event<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Event<'a>

§

impl<'a> RefUnwindSafe for Event<'a>

§

impl<'a> Send for Event<'a>

§

impl<'a> Sync for Event<'a>

§

impl<'a> Unpin for Event<'a>

§

impl<'a> UnsafeUnpin for Event<'a>

§

impl<'a> UnwindSafe for Event<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.