leap_client_rs

Crates.ioleap_client_rs
lib.rsleap_client_rs
version0.1.5
sourcesrc
created_at2022-09-04 21:01:41.094336
updated_at2023-10-08 01:33:34.063897
descriptionRust client library for the Leap Edge socket service
homepagehttps://hop.io
repositoryhttps://github.com/hopinc/leap_client_rs#readme
max_upload_size
id658452
size99,896
Kuba Ellwart (pxseu)

documentation

README

leap_edge_rs

Utility library for connecting and receiving events from Leap Edge. Used for Channels and Pipe.

Installation

Add this to your Cargo.toml:

[dependencies]
leap_edge_rs = "0.1"

or if you want to add features:

[dependencies.leap_edge_rs]
version = "0.1"
default-features = false
features = ["rustls-tls-webpki-roots", "zlib"]

Usage

Subscribe to a channel

use leap_edge_rs::{LeapEdge, LeapOptions, leap::types::Event};

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let leap = LeapEdge::new(LeapOptions {
        project: "my-project",
        ..Default::default()
    }).await?;

    leap.channel_subscribe("my-channel").await?;

    while let Some(event) = leap.listen().await {
        println!("{:?}", event);
    }
}

Get all events:

use leap_edge_rs::{LeapEdge, LeapOptions};

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let leap = LeapEdge::new(LeapOptions {
        project: "my-project",
        ..Default::default()
    }).await?;

    while let Some(event) = leap.listen().await {
        println!("{:?}", event);
    }
}

Get only messages or direct messages:

use leap_edge_rs::{LeapEdge, LeapOptions, leap::types::Event};

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    let leap = LeapEdge::new(LeapOptions {
        project: "my-project",
        ..Default::default()
    }).await?;

    while let Some(event) = leap.listen().await {
        match event {
            Event::Message(message) | Event::DirectMessage(message) => println!("{:?}", message),

            _ => {}
        }
    }
}
Commit count: 0

cargo fmt