#actix #telegram #derive #bot

macro actix-telegram-derive

derive for actix-telegram

5 releases

0.2.2 Feb 7, 2019
0.2.1 Jan 13, 2019
0.2.0 Nov 24, 2018
0.1.1 Sep 15, 2018
0.1.0 Sep 13, 2018
Download history 19/week @ 2018-11-26 20/week @ 2018-12-03 10/week @ 2018-12-10 13/week @ 2018-12-17 10/week @ 2018-12-24 4/week @ 2018-12-31 14/week @ 2019-01-07 14/week @ 2019-01-14 4/week @ 2019-01-21 5/week @ 2019-01-28 15/week @ 2019-02-04 3/week @ 2019-02-11 2/week @ 2019-02-18 23/week @ 2019-02-25 15/week @ 2019-03-04

42 downloads per month
Used in 1 crate

MIT license

27KB
685 lines

Rust telegram bot library

Crates.io Docs.rs

A rust library for writing telegram bot built on top of actix.

Official API.

Examples

example/polling.rs

example/server.rs

Usage

This library is available via crates.io. In order to use it, just add this to your Cargo.toml:

actix-telegram = "0.1.0-alpha5"

lib.rs:

Getset, we're ready to go!

A procedural macro for generating the most basic getters and setters on fields.

Getters are generated as fn field(&self) -> &type, while setters are generated as fn field(&mut self, val: type).

These macros are not intended to be used on fields which require custom logic inside of their setters and getters. Just write your own in that case!

#[macro_use]
extern crate getset;

#[derive(Getters, Setters, New, Default)]
#[get(vis = "pub")]
#[get(vis = "pub", mutable)]
#[set(vis = "pub", consume)]
#[set(vis = "pub")]
#[new(vis = "pub")]
pub struct Foo<T> where T: Copy + Clone + Default {
/// Doc comments are supported!
/// Multiline, even.
#[get(copy)] #[get(mutable)] #[set]
private: T,

/// Doc comments are supported!
/// Multiline, even.
public: Option<T>,

#[set(optional)]
optional: Option<String>,
}

fn main() {
let mut foo: Foo<i64> = Foo::new(1).consume_set_public(3);
assert_eq!(foo.private(), 1);
assert_eq!(*foo.public(), Some(3));
foo.set_private(3);
(*foo.private_mut()) += 1;
assert_eq!(foo.private(), 4);
foo.set_public(4);
assert_eq!(*foo.public(), Some(4));
foo.set_public(None);
assert_eq!(*foo.public(), None);
foo.set_optional(Some("test"));
assert_eq!(foo.optional(), &Some("test".to_string()));
foo.set_optional(None::<&str>);
assert_eq!(*foo.optional(), None);
}
#[macro_use]
extern crate getset;
mod submodule {
#[derive(Getters, Default)]
#[get = "pub"]
pub struct Foo {
#[get]
private: i32,
public: i32,
}
}
fn main() {
let mut foo = submodule::Foo::default();
assert_eq!(*foo.private(), 2);
}

Dependencies

~797KB
~18K SLoC