Skip to content

Commit

Permalink
Updating with StaticVersionType (#188)
Browse files Browse the repository at this point in the history
* Updating with StaticVersionType

* harmonizing test temp names, and an important dependency update

* Cargo.lock update

* dependency update
  • Loading branch information
nyospe authored Mar 14, 2024
1 parent 1f8515b commit d0d2bfb
Show file tree
Hide file tree
Showing 11 changed files with 334 additions and 268 deletions.
32 changes: 21 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tide-disco"
version = "0.4.7"
version = "0.4.8"
edition = "2021"
authors = ["Espresso Systems <[email protected]>"]
description = "Discoverability for Tide"
Expand Down Expand Up @@ -54,7 +54,7 @@ tracing-futures = "0.2"
tracing-log = "0.2.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
url = "2.5.0"
versioned-binary-serialization = { git = "https://github.com/EspressoSystems/versioned-binary-serialization.git", tag = "0.1.0" }
versioned-binary-serialization = { git = "https://github.com/EspressoSystems/versioned-binary-serialization.git", tag = "0.1.2" }

[target.'cfg(not(windows))'.dependencies]
signal-hook-async-std = "0.2.2"
Expand Down
10 changes: 7 additions & 3 deletions examples/hello-world/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use snafu::Snafu;
use std::io;
use tide_disco::{Api, App, Error, RequestError, StatusCode};
use tracing::info;
use versioned_binary_serialization::version::StaticVersion;

type StaticVer01 = StaticVersion<0, 1>;
const STATIC_VER: StaticVer01 = StaticVersion {};

#[derive(Clone, Debug, Deserialize, Serialize, Snafu)]
enum HelloError {
Expand Down Expand Up @@ -39,11 +43,11 @@ impl From<RequestError> for HelloError {
}

async fn serve(port: u16) -> io::Result<()> {
let mut app = App::<_, HelloError, 0, 1>::with_state(RwLock::new("Hello".to_string()));
let mut app = App::<_, HelloError, StaticVer01>::with_state(RwLock::new("Hello".to_string()));
app.with_version(env!("CARGO_PKG_VERSION").parse().unwrap());

let mut api =
Api::<RwLock<String>, HelloError, 0, 1>::from_file("examples/hello-world/api.toml")
Api::<RwLock<String>, HelloError, StaticVer01>::from_file("examples/hello-world/api.toml")
.unwrap();
api.with_version(env!("CARGO_PKG_VERSION").parse().unwrap());

Expand Down Expand Up @@ -75,7 +79,7 @@ async fn serve(port: u16) -> io::Result<()> {
.unwrap();

app.register_module("hello", api).unwrap();
app.serve(format!("0.0.0.0:{}", port)).await
app.serve(format!("0.0.0.0:{}", port), STATIC_VER).await
}

#[async_std::main]
Expand Down
Loading

0 comments on commit d0d2bfb

Please sign in to comment.