pub enum PushError {
Unregistered,
Rejected(String),
Transient {
message: String,
retry_after: Option<Duration>,
},
}Expand description
Push failures. Unregistered is separated because the caller must act on
it — the recipient is dead and should be pruned — where the others are
transient or a bad request.
The two variants that carry provider text are sanitized in Display,
the same way DbError’s and
MailError’s are (issue #235). What an adapter
wraps is the provider’s own words, and a push endpoint or a device
token is exactly the kind of value that rides in them. Display
therefore runs it through crate::logging::scrub_text; Debug
still shows the raw string for tests.
Variants§
Unregistered
The provider says the recipient is no longer valid (APNs 410, Web
Push 410, FCM UNREGISTERED): delete it.
This is a delete instruction, not a failed send, and an adapter
should map only a status whose sole meaning is “gone” onto it. A
status a misrouted proxy can also produce — Web Push 404, which
RFC 8030 never defines as gone — belongs in
Transient: the cost of a wrong Transient is
some wasted sends, and a wrongly-pruned Web Push subscription cannot
be recreated server-side at all, only by the browser subscribing
again.
Rejected(String)
The provider rejected the request (a 4xx that is not 410), or the
adapter does not serve this recipient’s transport; not retryable
without a change.
Transient
A transient failure (a 5xx, a 429, a transport error): retry
later, and not before retry_after when the provider named one
(APNs 429, FCM RESOURCE_EXHAUSTED/UNAVAILABLE, Web Push
429/503 — all carry Retry-After).
Implementations§
Source§impl PushError
impl PushError
Sourcepub fn transient(message: impl Into<String>) -> Self
pub fn transient(message: impl Into<String>) -> Self
A retryable failure with no provider-supplied delay.
Sourcepub fn transient_after(
message: impl Into<String>,
retry_after: Option<Duration>,
) -> Self
pub fn transient_after( message: impl Into<String>, retry_after: Option<Duration>, ) -> Self
A retryable failure the provider asked us to hold off on.
Sourcepub fn unsupported_recipient(recipient: &Recipient) -> Self
pub fn unsupported_recipient(recipient: &Recipient) -> Self
The rejection an adapter returns for a transport it does not serve.
RoutingPush exists so a venture never has to see this.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
How long the provider asked the caller to wait, where it said.
Trait Implementations§
impl Eq for PushError
Source§impl Error for PushError
impl Error for PushError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl StructuralPartialEq for PushError
Auto Trait Implementations§
impl Freeze for PushError
impl RefUnwindSafe for PushError
impl Send for PushError
impl Sync for PushError
impl Unpin for PushError
impl UnsafeUnpin for PushError
impl UnwindSafe for PushError
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.