pub struct RpcError {
pub code: i32,
pub name: String,
pub value: Option<u32>,
}Expand description
An error returned by Telegram’s servers in response to an RPC call.
Numeric values are stripped from the name and placed in RpcError::value.
§Example
FLOOD_WAIT_30 → RpcError { code: 420, name: "FLOOD_WAIT", value: Some(30) }
Fields§
§code: i32HTTP-like status code.
name: StringError name in SCREAMING_SNAKE_CASE with digits removed.
value: Option<u32>Numeric suffix extracted from the name, if any.
Implementations§
Source§impl RpcError
impl RpcError
Sourcepub fn from_telegram(code: i32, message: &str) -> Self
pub fn from_telegram(code: i32, message: &str) -> Self
Parse a raw Telegram error message like "FLOOD_WAIT_30" into an RpcError.
Sourcepub fn is(&self, pattern: &str) -> bool
pub fn is(&self, pattern: &str) -> bool
Match on the error name, with optional wildcard prefix/suffix '*'.
§Examples
err.is("FLOOD_WAIT")— exact matcherr.is("PHONE_CODE_*")— starts-with matcherr.is("*_INVALID")— ends-with match
Sourcepub fn flood_wait_seconds(&self) -> Option<u64>
pub fn flood_wait_seconds(&self) -> Option<u64>
Returns the flood-wait duration in seconds, if this is a FLOOD_WAIT error.
Trait Implementations§
Source§impl Error for RpcError
impl Error for RpcError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl StructuralPartialEq for RpcError
Auto Trait Implementations§
impl Freeze for RpcError
impl RefUnwindSafe for RpcError
impl Send for RpcError
impl Sync for RpcError
impl Unpin for RpcError
impl UnsafeUnpin for RpcError
impl UnwindSafe for RpcError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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