Struct twitch_api2::eventsub::Payload
source · [−]#[non_exhaustive]pub struct Payload<E: EventSubscription + Clone> {
pub subscription: EventSubscriptionInformation<E>,
pub message: Message<E>,
}
eventsub
only.Expand description
Notification received
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.subscription: EventSubscriptionInformation<E>
Subscription information.
message: Message<E>
Event information.
Implementations
sourceimpl<E: EventSubscription> Payload<E>
impl<E: EventSubscription> Payload<E>
sourcepub fn parse(source: &str) -> Result<Payload<E>, PayloadParseError>
pub fn parse(source: &str) -> Result<Payload<E>, PayloadParseError>
Parse string slice as a Payload
, this will assume your string is from an eventsub message with type notification
sourcepub fn parse_notification(source: &str) -> Result<Payload<E>, PayloadParseError>
pub fn parse_notification(source: &str) -> Result<Payload<E>, PayloadParseError>
Parse string slice as a Payload
with a message of Message::Notification
.
sourcepub fn parse_revocation(source: &str) -> Result<Payload<E>, PayloadParseError>
pub fn parse_revocation(source: &str) -> Result<Payload<E>, PayloadParseError>
Parse string slice as a Payload
with a message of Message::Revocation
.
sourcepub fn parse_verification_request(
source: &str
) -> Result<Payload<E>, PayloadParseError>
pub fn parse_verification_request(
source: &str
) -> Result<Payload<E>, PayloadParseError>
Parse string slice as a Payload
with a message of Message::VerificationRequest
.
sourcepub fn parse_http<B>(
request: &Request<B>
) -> Result<Payload<E>, PayloadParseError> where
B: AsRef<[u8]>,
pub fn parse_http<B>(
request: &Request<B>
) -> Result<Payload<E>, PayloadParseError> where
B: AsRef<[u8]>,
Parse http post request as a Payload with a specific event.
If you don’t know what event this payload is, use Event::parse_http
instead.
If your Request<B>
is of another type that doesn’t implement AsRef<[u8]>
, try converting it with Request::map
use http::Request;
use twitch_api2::eventsub::{Payload, channel::ChannelFollowV1};
// Example of a request with a body that doesn't implement `AsRef<[u8]>`
let original_request: Request<Body> = http::Request::new(Body::new());
// Convert to a request with a body of `Vec<u8>`, which does implement `AsRef<[u8]>`
let converted_request: Request<Vec<u8>> = original_request.map(|r| r.to_bytes().to_owned());
Payload::<ChannelFollowV1>::parse_http(&converted_request)?
sourceimpl<E: EventSubscription + Clone> Payload<E>
impl<E: EventSubscription + Clone> Payload<E>
sourcepub fn get_event_type(&self) -> EventType
pub fn get_event_type(&self) -> EventType
Convenience method for getting the event type from the payload.
sourcepub fn get_event_version(&self) -> &'static str
pub fn get_event_version(&self) -> &'static str
Convenience method for getting the event version from the payload.
Trait Implementations
sourceimpl<'de, E: EventSubscription + Clone> Deserialize<'de> for Payload<E> where
E: EventSubscription,
E: EventSubscription,
impl<'de, E: EventSubscription + Clone> Deserialize<'de> for Payload<E> where
E: EventSubscription,
E: EventSubscription,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<E: EventSubscription + Clone> Serialize for Payload<E> where
E: EventSubscription,
E: EventSubscription,
impl<E: EventSubscription + Clone> Serialize for Payload<E> where
E: EventSubscription,
E: EventSubscription,
impl<E: EventSubscription + Clone> StructuralPartialEq for Payload<E>
Auto Trait Implementations
impl<E> RefUnwindSafe for Payload<E> where
E: RefUnwindSafe,
<E as EventSubscription>::Payload: RefUnwindSafe,
impl<E> Send for Payload<E> where
E: Send,
<E as EventSubscription>::Payload: Send,
impl<E> Sync for Payload<E> where
E: Sync,
<E as EventSubscription>::Payload: Sync,
impl<E> Unpin for Payload<E> where
E: Unpin,
<E as EventSubscription>::Payload: Unpin,
impl<E> UnwindSafe for Payload<E> where
E: UnwindSafe,
<E as EventSubscription>::Payload: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more