dlist-top

Crates.iodlist-top
lib.rsdlist-top
version0.1.0
sourcesrc
created_at2021-07-28 11:58:57.374706
updated_at2021-07-28 11:58:57.374706
descriptionOfficial DList.top client for Rust
homepagehttps://github.com/dlist-top/client-rs
repositoryhttps://github.com/dlist-top/client-rs
max_upload_size
id428320
size51,240
Jakub (jakub-lat)

documentation

README

DList.top Rust client

Official dlist.top gateway client for Rust.

Installation

[dependencies]
dlist_top = "*"

Setup

To get your token please refer to the DList.top documentation.

Usage

use dlist_top::{Client, EventHandler};
use dlist_top::events::{VoteData, RateData};
use dlist_top::entity::Entity;
use async_trait::async_trait;
use tracing_subscriber::FmtSubscriber;
use tracing::Level;

struct DlistEvents;

#[async_trait]
impl EventHandler for DlistEvents {
    async fn on_ready(&self, _entity: &Entity) {
        println!("DList.top ready!");
    }
    async fn on_disconnect(&self, reason: &str) {
        println!("DList.top disconnected with reason: {}", reason)
    }
    async fn on_vote(&self, data: VoteData) {
        println!("vote! {:?}", data);
    }
    async fn on_rate(&self, data: RateData) {
        println!("rate! {:?}", data);
    }
}


#[tokio::main]
async fn main() {
    let subscriber = FmtSubscriber::builder()
        .with_max_level(Level::INFO)
        .finish();

    tracing::subscriber::set_global_default(subscriber)
        .expect("setting default subscriber failed");

    let mut client = Client::new("TOKEN", DlistEvents);
    client.connect().await;
}

Commit count: 4

cargo fmt