-
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.
feat: Added methods to make update listeners onto the client
BREAKING CHANGE: Deprecated warframe-macros and changed project structure
- Loading branch information
1 parent
9948bca
commit 16bd7be
Showing
52 changed files
with
712 additions
and
572 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,2 +1,38 @@ | ||
[package] | ||
name = "warframe" | ||
version = "3.1.1" | ||
edition = "2021" | ||
description = "An async crate to wrap Warframe's Worldstate API." | ||
readme = "./README.md" | ||
documentation = "https://docs.rs/warframe" | ||
homepage = "https://docs.rs/warframe" | ||
repository = "https://github.com/Mettwasser/warframe.rs" | ||
license = "MIT" | ||
|
||
|
||
[features] | ||
default = ["worldstate"] | ||
|
||
worldstate = [] | ||
multilangual = ["worldstate"] | ||
worldstate_listeners = ["worldstate"] | ||
worldstate_full = ["worldstate", "multilangual", "worldstate_listeners"] | ||
|
||
[dev-dependencies] | ||
clippy = "0.0.302" | ||
rustfmt = "0.10.0" | ||
|
||
[dependencies] | ||
tokio = { version = "1.34.0", features = ["full"]} | ||
reqwest = { version = "0.11.22", features = ["json"] } | ||
chrono = { version = "0.4.31", features = ["serde", "clock"] } | ||
serde = { version = "1.0.190", features = ["derive"] } | ||
serde_json = { version = "1.0.108" } | ||
serde_flat_path = "0.1.2" | ||
serde_repr = "0.1.18" | ||
futures = "0.3.30" | ||
log = "0.4.20" | ||
env_logger = "0.11.1" | ||
|
||
[workspace] | ||
members = ["warframe.rs", "warframe-macros", "examples/*"] | ||
members = [ "examples/*"] |
7 changes: 3 additions & 4 deletions
7
...les/listener_object_with_state/Cargo.toml → examples/listen_to_nested_updates/Cargo.toml
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
[package] | ||
name = "example-listener-object" | ||
name = "listen_to_nested_updates" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
warframe = { path = "../../warframe.rs/", features = ["worldstate", "macros"] } | ||
warframe = { path = "../../", features = ["worldstate", "worldstate_listeners"] } | ||
tokio = { version = "1.34.0", features = ["full"] } | ||
env_logger = "0.11.1" | ||
tokio = "1.36.0" | ||
log = "0.4.20" |
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,29 @@ | ||
use std::error::Error; | ||
|
||
use warframe::worldstate::{listener::Change, prelude::*}; | ||
|
||
/// This function will be called once a fissure updates. | ||
/// This will send a request to the corresponding endpoint once every 30s | ||
/// and compare the results for changes. | ||
async fn on_fissure_update(fissure: Change<'_, Fissure>) { | ||
match fissure { | ||
Change::Added(fissure) => println!("Fissure ADDED : {fissure:?}"), | ||
Change::Removed(fissure) => println!("Fissure REMOVED : {fissure:?}"), | ||
} | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
// Logging setup | ||
env_logger::builder() | ||
.filter_level(log::LevelFilter::Debug) | ||
.init(); | ||
|
||
// initialize a client (included in the prelude) | ||
let client = Client::new(); | ||
|
||
// Pass the function to the handler | ||
// (will return a Future) | ||
client.call_on_nested_update(on_fissure_update).await?; | ||
Ok(()) | ||
} |
7 changes: 3 additions & 4 deletions
7
examples/listener_array/Cargo.toml → examples/listen_to_updates/Cargo.toml
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
[package] | ||
name = "example-listener-array" | ||
name = "listen_to_updates" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
warframe = { path = "../../warframe.rs/", features = ["worldstate", "macros"]} | ||
warframe = { path = "../../", features = ["worldstate", "worldstate_listeners"] } | ||
tokio = { version = "1.34.0", features = ["full"] } | ||
env_logger = "0.11.1" | ||
tokio = "1.36.0" | ||
log = "0.4.20" |
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,20 @@ | ||
use std::error::Error; | ||
|
||
use warframe::worldstate::prelude::*; | ||
|
||
async fn on_cetus_update(before: &Cetus, after: &Cetus) { | ||
println!("BEFORE : {before:?}"); | ||
println!("AFTER : {after:?}"); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
env_logger::builder() | ||
.filter_level(log::LevelFilter::Debug) | ||
.init(); | ||
|
||
let client = Client::new(); | ||
|
||
client.call_on_update(on_cetus_update).await?; | ||
Ok(()) | ||
} |
7 changes: 3 additions & 4 deletions
7
examples/listener_object/Cargo.toml → ...s/listen_to_updates_with_state/Cargo.toml
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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
[package] | ||
name = "example-listener-object-with-state" | ||
name = "listen_to_updates_with_state" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
warframe = { path = "../../warframe.rs/", features = ["worldstate", "macros"] } | ||
warframe = { path = "../../", features = ["worldstate", "worldstate_listeners"] } | ||
tokio = { version = "1.34.0", features = ["full"] } | ||
env_logger = "0.11.1" | ||
tokio = "1.36.0" | ||
log = "0.4.20" |
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,36 @@ | ||
use std::{error::Error, sync::Arc}; | ||
|
||
use warframe::worldstate::prelude::*; | ||
|
||
// Define some state | ||
#[derive(Debug)] | ||
struct MyState { | ||
_num: i32, | ||
_s: String, | ||
} | ||
|
||
async fn on_cetus_update(state: Arc<MyState>, before: &Cetus, after: &Cetus) { | ||
println!("STATE : {state:?}"); | ||
println!("BEFORE : {before:?}"); | ||
println!("AFTER : {after:?}"); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
env_logger::builder() | ||
.filter_level(log::LevelFilter::Debug) | ||
.init(); | ||
|
||
let client = Client::new(); | ||
|
||
// Note that the state will be cloned into the handler, so Arc is preferred | ||
let state = Arc::new(MyState { | ||
_num: 69, | ||
_s: "My ginormous ass".into(), | ||
}); | ||
|
||
client | ||
.call_on_update_with_state(on_cetus_update, state) | ||
.await?; | ||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.