mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 15:49:27 +01:00
Improve bot/mod.rs
This commit is contained in:
parent
ceaf36b101
commit
495e62e9aa
1 changed files with 12 additions and 5 deletions
|
@ -11,28 +11,35 @@ pub struct Bot {
|
||||||
client: Client,
|
client: Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructors
|
|
||||||
impl Bot {
|
impl Bot {
|
||||||
pub fn new(token: &str) -> Self {
|
pub fn new<S>(token: S) -> Self
|
||||||
|
where
|
||||||
|
S: Into<String>,
|
||||||
|
{
|
||||||
Bot {
|
Bot {
|
||||||
token: String::from(token),
|
token: token.into(),
|
||||||
client: Client::new(),
|
client: Client::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_client(token: &str, client: Client) -> Self {
|
pub fn with_client<S>(token: S, client: Client) -> Self
|
||||||
|
where
|
||||||
|
S: Into<String>,
|
||||||
|
{
|
||||||
Bot {
|
Bot {
|
||||||
token: String::from(token),
|
token: token.into(),
|
||||||
client,
|
client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bot {
|
impl Bot {
|
||||||
|
#[inline]
|
||||||
pub fn token(&self) -> &str {
|
pub fn token(&self) -> &str {
|
||||||
&self.token
|
&self.token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn client(&self) -> &Client {
|
pub fn client(&self) -> &Client {
|
||||||
&self.client
|
&self.client
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue