Skip to main content

Request

Struct Request 

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

One request on its way to the app thread. Answer it with Request::reply (or a shortcut); a request dropped unanswered replies with an error by itself, so the connection never hangs. It may be kept and answered on a later frame (the element is not on screen yet, a screenshot needs the next paint).

Implementations§

Source§

impl Request

Source

pub fn new(method: impl Into<String>, params: Value) -> (Self, Receiver<Reply>)

A request and the receiver its reply arrives on. params that are null become {}.

Source

pub fn method(&self) -> &str

Source

pub fn params(&self) -> &Value

Source

pub fn reply(self, r: Reply)

Answer. The receiver may be gone (the connection closed or timed out): that is fine.

Source

pub fn ok(self, v: Value)

Source

pub fn fail(self, e: impl Display)

Source

pub fn unknown(self)

The standard answer for a method nobody handles.

Trait Implementations§

Source§

impl Debug for Request

Source§

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

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

impl Drop for Request

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.

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, 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.