diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5055554..f551f32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: - name: Tests run: nix develop --command cargo test + - name: Build examples + run: nix develop --command cargo build --examples + build: name: Build needs: diff --git a/Cargo.lock b/Cargo.lock index e5b93a6..5d48afe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -425,11 +425,13 @@ dependencies = [ name = "emfcamp-schedule-api" version = "0.0.1" dependencies = [ + "anyhow", "chrono", "reqwest", "serde", "serde_json", "serde_with", + "tokio", "url", ] diff --git a/client/Cargo.toml b/client/Cargo.toml index 89022c4..e59f7cf 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -11,3 +11,7 @@ serde.workspace = true serde_json.workspace = true serde_with.workspace = true url.workspace = true + +[dev-dependencies] +anyhow.workspace = true +tokio.workspace = true diff --git a/client/examples/now_and_next.rs b/client/examples/now_and_next.rs new file mode 100644 index 0000000..d1dc86f --- /dev/null +++ b/client/examples/now_and_next.rs @@ -0,0 +1,19 @@ +use anyhow::Result; +use chrono::Local; +use url::Url; + +#[tokio::main] +async fn main() -> Result<()> { + let url = Url::parse("https://www.emfcamp.org/schedule/2022.json")?; + + let client = emfcamp_schedule_api::Client::new(url); + + let schedule = client.get_schedule().await?; + + let now = Local::now(); + let now_and_next = schedule.now_and_next(now.into()); + + println!("{:#?}", now_and_next); + + Ok(()) +} diff --git a/client/examples/schedule.rs b/client/examples/schedule.rs new file mode 100644 index 0000000..9c37618 --- /dev/null +++ b/client/examples/schedule.rs @@ -0,0 +1,18 @@ +use anyhow::Result; +use url::Url; + +#[tokio::main] +async fn main() -> Result<()> { + let url = Url::parse("https://www.emfcamp.org/schedule/2022.json")?; + + let client = emfcamp_schedule_api::Client::new(url); + + let schedule = client.get_schedule().await?; + + println!("Found {} events", schedule.events.len()); + for event in schedule.events { + println!("- {:?}", event); + } + + Ok(()) +} diff --git a/client/examples/venues.rs b/client/examples/venues.rs new file mode 100644 index 0000000..20299e1 --- /dev/null +++ b/client/examples/venues.rs @@ -0,0 +1,20 @@ +use anyhow::Result; +use url::Url; + +#[tokio::main] +async fn main() -> Result<()> { + let url = Url::parse("https://www.emfcamp.org/schedule/2022.json")?; + + let client = emfcamp_schedule_api::Client::new(url); + + let schedule = client.get_schedule().await?; + + let venues = schedule.venues(); + + println!("Found {} venues:", venues.len()); + for venue in venues { + println!("- {}", venue); + } + + Ok(()) +} diff --git a/flake.nix b/flake.nix index 1a6b36b..5d757c8 100644 --- a/flake.nix +++ b/flake.nix @@ -24,8 +24,6 @@ version = cargoToml.workspace.package.version; gitRevision = self.shortRev or self.dirtyShortRev; - - lintingRustFlags = "-D unused-crate-dependencies"; in rec { devShell = pkgs.mkShell { packages = with pkgs; [ @@ -49,8 +47,6 @@ # Container image management tool skopeo ]; - - RUSTFLAGS = lintingRustFlags; }; packages =