Skip to main content

PairCodeRejection

Enum PairCodeRejection 

Source
pub enum PairCodeRejection {
    BadRequest,
    Forbidden,
    RateOverlimit,
    FeatureNotAvailable,
    InternalServerError,
    Unknown(i32),
}
Expand description

How the server refused a pair-code request, as a matchable status.

The five named variants are the complete set WA Web’s own response parser accepts (WASmaxInMdIqMixinErrors.parseIqMixinErrors, reached from WASmaxInMdCompanionHelloResponseError); anything else makes its RPC throw “unknown error”. They exist so a consumer can branch on the refusal instead of matching the formatted message, which is not a stable surface.

Both stages report through this, though they were read off companion_hello and the companion_finish parser is narrower — WASmaxInMdCompanionFinishErrors admits only bad-request and internal-server-error, and WA Web shows its generic failure for anything else. A code outside that pair is still classified here rather than discarded: what a consumer does about a refusal follows from the code, which is one namespace across both requests, and answering “nothing was refused” to a refusal we can read would be worse than naming it.

The numbers are the code attribute, and each is the enum’s whole wire form — code() is what Serialize emits and what From<i32> reads back. WA Web pairs each code with a literal text (429/rate-overlimit, 452/feature-not-available, …) and rejects a response whose two disagree, so construct these through from_server rather than from a code alone: it is the only constructor that sees both attributes, and the only one that can decline to classify.

WA Web branches on exactly two of them (DevicePhoneNumberCodeScreen, on CompanionHelloError.type.name): RateOverlimit becomes “too many attempts, try again later” and FeatureNotAvailable becomes “not available to you yet, link with QR code instead”. The rest share a generic “try again or link with the QR code”. In every case it resets the linking flow and waits for the person to act — it never retries on its own, and never reads the backoff hint, so treat that value as the server’s advice rather than a schedule WA Web is known to follow.

Variants§

§

BadRequest

The request was malformed — or throttled for this phone number: the server reuses bad-request for its per-number pair-code limit rather than answering rate-overlimit. So this is not reliably a permanent failure; see PairCodeRejection::is_throttled.

§

Forbidden

§

RateOverlimit

The connection is asking for codes too fast. The server states the rate is too high; the only correct response is to slow down.

§

FeatureNotAvailable

Phone-number linking is not enabled for this account. Retrying will not change that — WA Web sends the user to the QR code instead.

§

InternalServerError

§

Unknown(i32)

A code outside the set WA Web accepts. Its own RPC would raise “unknown error” here; we keep the number so a consumer can log it and a server-side addition is visible rather than silently reshaped.

Implementations§

Source§

impl PairCodeRejection

Source

pub fn code(&self) -> i32

Numeric wire code for this variant (single source of truth).

Source§

impl PairCodeRejection

Source

pub fn is_throttled(self) -> bool

Whether this refusal is the server rate-limiting the request.

True for RateOverlimit and BadRequest, because the server throttles pair-code requests per phone number under bad-request instead of rate-overlimit. That makes the predicate deliberately wider than the literal 429: a bad-request may equally be genuinely invalid content, and the two are indistinguishable on the wire. Treat a true here as “back off, then retry at most a bounded number of times” — not as proof the request would ever succeed.

Source

pub fn text(self) -> Option<&'static str>

The text WA Web pairs with this code; None for Unknown, which has no expected pairing.

Source

pub fn from_server(code: u16, text: &str) -> Option<PairCodeRejection>

Classify a server <error> from both of its attributes, or None when the two disagree and no classification is honest.

WA Web asserts the pair (literal(attrInt, …, "code", 429) beside literal(attrString, …, "text", "rate-overlimit")) and drops to its generic error path when they disagree, so a changed pairing must not keep reading as the named arm.

None rather than Unknown(code) for that case, because Unknown could not carry it: the wire form of this enum is code(), so Unknown(429) serializes to 429 and rehydrates as RateOverlimit — a consumer that persisted or forwarded the value would get the demotion silently undone and apply throttling anyway. There is no in-band value that both records the code and refuses to alias the arm it came from. The code is not lost: the caller still has the error’s own rendering, which names it.

An absent text is not a contradiction, and the code alone decides. Deliberately laxer than WA Web, which would reject it: refusing to classify a bare 429 would also clear is_throttled, turning the one refusal a consumer most needs to act on back into a silent one. A missing attribute is not evidence that the code means something else.

Trait Implementations§

Source§

impl Clone for PairCodeRejection

Source§

fn clone(&self) -> PairCodeRejection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PairCodeRejection

Source§

impl Debug for PairCodeRejection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PairCodeRejection

Source§

fn deserialize<D>( deserializer: D, ) -> Result<PairCodeRejection, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PairCodeRejection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for PairCodeRejection

Source§

impl From<i32> for PairCodeRejection

Source§

fn from(code: i32) -> PairCodeRejection

Converts to this type from the input type.
Source§

impl PartialEq for PairCodeRejection

Source§

fn eq(&self, other: &PairCodeRejection) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PairCodeRejection

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PairCodeRejection

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Spawnable for T
where T: Send + 'static,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more