Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating with StaticVersionType #188

Merged
merged 4 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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.1" }

[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 Ver01 = StaticVersion<0, 1>;
const STATIC_VER: Ver01 = 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, Ver01>::with_state(RwLock::new("Hello".to_string()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really familiar with the code in this repo, but it looks like there are multiple different names for the same thing. Is this intentional?

There's Ver01 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not so much intentional as the inevitable consequence of how rust's doctest works. Each doctest instance is basically its own isolated sandbox. Likewise for examples. There's nothing special about these aliases, they're just convent for illustrating that, in real usage, you would be using something external rather than hardcoding StaticVersion<0, 1> as a parameter.

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, Ver01>::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
Loading