-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @pxseu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# leap_edge_rs | ||
|
||
Utility library for connecting and receiving events from [Leap Edge](https://docs.hop.io/docs/channels/internals/leap). Used for Channels and Pipe. | ||
|
||
## Installation | ||
|
||
Add this to your `Cargo.toml`: | ||
|
||
```toml | ||
[dependencies] | ||
leap_edge_rs = "0.1" | ||
``` | ||
|
||
or if you want to add features: | ||
|
||
```toml | ||
[dependencies.leap_edge_rs] | ||
version = "0.1" | ||
default-features = false | ||
features = ["rustls-tls-webpki-roots", "zlib"] | ||
``` | ||
|
||
## Usage | ||
|
||
### Subscribe to a channel | ||
|
||
```rust | ||
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: | ||
|
||
```rust | ||
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: | ||
|
||
```rust | ||
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), | ||
|
||
_ => {} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters