pub struct BotToken(/* private fields */);Expand description
A Telegram bot token.
The token is a credential which grants full control of the bot, and it is sent to Telegram as a path segment of every request URL. That makes it unusually easy to leak: any error type, log line, or panic message which includes the request URL includes the token.
This type therefore refuses to print itself. Both Debug and Display
render ***, so a {:?} of any struct holding a BotToken is safe. The
raw value is reachable only via the crate-private BotToken::expose.
Implementations§
Source§impl BotToken
impl BotToken
Sourcepub fn new(token: impl Into<String>) -> Result<Self, TelegramError>
pub fn new(token: impl Into<String>) -> Result<Self, TelegramError>
Creates a new BotToken, validating that it is plausibly a token.
Blank-but-present is treated as missing: a server which boots with an empty token looks healthy while silently notifying nobody.
§Errors
Returns TelegramError::InvalidToken if the token is empty after
trimming, or if it does not contain the <bot_id>:<secret> separator.
Trait Implementations§
impl Eq for BotToken
impl StructuralPartialEq for BotToken
Auto Trait Implementations§
impl Freeze for BotToken
impl RefUnwindSafe for BotToken
impl Send for BotToken
impl Sync for BotToken
impl Unpin for BotToken
impl UnsafeUnpin for BotToken
impl UnwindSafe for BotToken
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.