pub struct WebSubSubscriber {
pub callback_url: String,
pub secret: Option<String>,
}Expand description
Builds subscription requests and handles incoming WebSub callbacks.
Fields§
§callback_url: StringThe callback URL this subscriber exposes.
secret: Option<String>Optional HMAC-SHA256 secret for signature verification.
Implementations§
Source§impl WebSubSubscriber
impl WebSubSubscriber
Sourcepub fn new(callback_url: impl Into<String>) -> Self
pub fn new(callback_url: impl Into<String>) -> Self
Create a subscriber with the given callback URL and no secret.
Sourcepub fn with_secret(self, secret: impl Into<String>) -> Self
pub fn with_secret(self, secret: impl Into<String>) -> Self
Attach an HMAC secret (builder style).
Sourcepub fn subscribe_params(
&self,
hub_url: &str,
topic_url: &str,
lease_seconds: u64,
) -> Vec<(String, String)>
pub fn subscribe_params( &self, hub_url: &str, topic_url: &str, lease_seconds: u64, ) -> Vec<(String, String)>
Return the form-encoded parameters for a subscribe request.
Sourcepub fn unsubscribe_params(
&self,
hub_url: &str,
topic_url: &str,
) -> Vec<(String, String)>
pub fn unsubscribe_params( &self, hub_url: &str, topic_url: &str, ) -> Vec<(String, String)>
Return the form-encoded parameters for an unsubscribe request.
Sourcepub fn verify_intent(
&self,
mode: &str,
topic: &str,
challenge: &str,
_lease_seconds: Option<u64>,
) -> Result<String>
pub fn verify_intent( &self, mode: &str, topic: &str, challenge: &str, _lease_seconds: Option<u64>, ) -> Result<String>
Handle the hub’s intent-verification GET request.
The WebSub spec requires the subscriber to echo back the challenge
when it agrees with the mode and topic. Returns Ok(challenge).
Sourcepub fn verify_signature(
&self,
body: &[u8],
signature_header: &str,
) -> Result<bool>
pub fn verify_signature( &self, body: &[u8], signature_header: &str, ) -> Result<bool>
Verify the X-Hub-Signature header on an incoming notification.
The header format is sha256=<hex-digest>. Returns Ok(true) on
success, Ok(false) if the signature does not match, and Err when
no secret is configured or the header is malformed.
Sourcepub fn compute_signature(&self, body: &[u8]) -> Result<String>
pub fn compute_signature(&self, body: &[u8]) -> Result<String>
Compute the X-Hub-Signature header value for a notification body.
Useful for hub implementations that need to sign outgoing content.
Trait Implementations§
Source§impl Clone for WebSubSubscriber
impl Clone for WebSubSubscriber
Source§fn clone(&self) -> WebSubSubscriber
fn clone(&self) -> WebSubSubscriber
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WebSubSubscriber
impl RefUnwindSafe for WebSubSubscriber
impl Send for WebSubSubscriber
impl Sync for WebSubSubscriber
impl Unpin for WebSubSubscriber
impl UnsafeUnpin for WebSubSubscriber
impl UnwindSafe for WebSubSubscriber
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.