pub struct DynResponse { /* private fields */ }Expand description
A type-erased response payload.
The concrete type’s identity is captured at construction, where the type
is statically known. This matters because Box<dyn ResponseData> itself
satisfies the ResponseData blanket impl: identity queried through a
box via method calls would resolve to the box’s impl and report the
box’s TypeId rather than the payload’s, silently breaking dispatch.
Implementations§
Source§impl DynResponse
impl DynResponse
Sourcepub fn new<T: ResponseData>(data: T) -> Self
pub fn new<T: ResponseData>(data: T) -> Self
Erase a concrete payload, capturing its type identity.
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The type name of the concrete payload, for unhandled-payload warnings.
Sourcepub fn downcast<T: ResponseData>(self) -> Result<T, Self>
pub fn downcast<T: ResponseData>(self) -> Result<T, Self>
Downcast to the concrete payload type.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DynResponse
impl !UnwindSafe for DynResponse
impl Freeze for DynResponse
impl Send for DynResponse
impl Sync for DynResponse
impl Unpin for DynResponse
impl UnsafeUnpin for DynResponse
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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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