wlan_fidl_ext::responder_ext

Trait ResponderExt

Source
pub trait ResponderExt {
    type Response;

    const REQUEST_NAME: &'static str;

    // Required method
    fn send(self, response: Self::Response) -> Result<(), Error>;

    // Provided methods
    fn unpack_fields_or_else_send<T, F>(
        self,
        fields: T,
        f: F,
    ) -> Result<(T::Unpacked, Self), Error>
       where T: TryUnpack<Error = Error>,
             F: FnOnce() -> Self::Response,
             Self: Sized { ... }
    fn unpack_fields_or_respond<T>(
        self,
        fields: T,
    ) -> Result<(T::Unpacked, Self), Error>
       where T: TryUnpack<Error = Error>,
             Self: ResponderExt<Response = ()> + Sized { ... }
}
Expand description

Defines an abstract ResponderExt trait usually implemented using the impl_responder_ext!() macro.

Required Associated Constants§

Source

const REQUEST_NAME: &'static str

Required Associated Types§

Required Methods§

Source

fn send(self, response: Self::Response) -> Result<(), Error>

Provided Methods§

Source

fn unpack_fields_or_else_send<T, F>( self, fields: T, f: F, ) -> Result<(T::Unpacked, Self), Error>
where T: TryUnpack<Error = Error>, F: FnOnce() -> Self::Response, Self: Sized,

Returns an success value containing all unpacked fields and the responder, or an error value if any of the values in fields is missing.

The last argument is a closure which will compute a Self::Response. If any field is missing a value, then this function will return an error and send the computed Self::Response.

Example Usage:

  enum Error {
      UnableToStart,
  }
  let ((status, id), responder) = responder.unpack_fields_or_else_send(
      (payload.status.with_name("status"), payload.id.with_name("id")),
      |e| (e.context(format_err!("Unable to start.")), Error::UnableToStart),
  )?;
Source

fn unpack_fields_or_respond<T>( self, fields: T, ) -> Result<(T::Unpacked, Self), Error>
where T: TryUnpack<Error = Error>, Self: ResponderExt<Response = ()> + Sized,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ResponderExt for WlanSoftmacIfcBridgeNotifyScanCompleteResponder

Source§

const REQUEST_NAME: &'static str = "fidl_softmac::WlanSoftmacIfcBaseNotifyScanCompleteRequest"

Source§

type Response = ()

Source§

fn send(self, _: Self::Response) -> Result<(), Error>

Source§

impl ResponderExt for WlanSoftmacIfcBridgeReportTxResultResponder

Source§

const REQUEST_NAME: &'static str = "fidl_softmac::WlanSoftmacIfcBaseReportTxResultRequest"

Source§

type Response = ()

Source§

fn send(self, _: Self::Response) -> Result<(), Error>

Implementors§