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

Implements ExtensionProvider for Option<E> #53

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-features --all-targets --workspace -- -D warnings

semver:
name: Check semver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: obi1kenobi/cargo-semver-checks-action@v2

autobahnclient:
name: Autobahn Client
runs-on: ubuntu-latest
Expand Down
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ members = [
]

[workspace.package]
version = "1.1.0"
version = "1.1.1"
authors = ["Swim Inc. developers [email protected]"]
edition = "2021"
categories = ["network-programming", "asynchronous", "web-programming::websocket"]
license = "Apache-2.0"

[workspace.dependencies]
ratchet = { package = "ratchet_rs", version = "1.1.1", path = "ratchet_rs" }
ratchet_core = { version = "1.1.1", path = "ratchet_core" }
ratchet_ext = { version = "1.1.1", path = "ratchet_ext" }
ratchet_deflate = { version = "1.1.1", path = "ratchet_deflate" }
ratchet_fixture = { version = "1.1.1", path = "ratchet_fixture" }

url = "2.1.1"
http = "1.1.0"
tokio = "1.22"
Expand Down
2 changes: 1 addition & 1 deletion ratchet_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ split = ["futures"]
fixture = []

[dependencies]
ratchet_ext = { version = "1.0.3", path = "../ratchet_ext" }
ratchet_ext = { workspace = true }
url = { workspace = true }
http = { workspace = true }
tokio = { workspace = true, features = ["rt", "net", "io-util"] }
Expand Down
2 changes: 1 addition & 1 deletion ratchet_deflate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license.workspace = true
categories.workspace = true

[dependencies]
ratchet_ext = { version = "1.0.3", path = "../ratchet_ext" }
ratchet_ext = { workspace = true }
thiserror = { workspace = true }
http = { workspace = true }
bytes = { workspace = true }
Expand Down
34 changes: 34 additions & 0 deletions ratchet_ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,40 @@ where
}
}

impl<E> ExtensionProvider for Option<E>
where
E: ExtensionProvider,
{
type Extension = E::Extension;
type Error = E::Error;

fn apply_headers(&self, headers: &mut HeaderMap) {
if let Some(provider) = self {
provider.apply_headers(headers);
}
}

fn negotiate_client(
&self,
headers: &HeaderMap,
) -> Result<Option<Self::Extension>, Self::Error> {
match self {
Some(ext) => ext.negotiate_client(headers),
None => Ok(None),
}
}

fn negotiate_server(
&self,
headers: &HeaderMap,
) -> Result<Option<(Self::Extension, HeaderValue)>, Self::Error> {
match self {
Some(ext) => ext.negotiate_server(headers),
None => Ok(None),
}
}
}

/// A data code for a frame.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum OpCode {
Expand Down
2 changes: 1 addition & 1 deletion ratchet_fixture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license.workspace = true
categories.workspace = true

[dependencies]
ratchet = { package = "ratchet_rs", version = "1.0.3", path = "../ratchet_rs", features = ["split", "deflate", "fixture"] }
ratchet = { workspace = true, features = ["split", "deflate", "fixture"] }
tokio = { workspace = true, features = ["io-util"] }
bytes = { workspace = true }
futures = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions ratchet_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ split = ["ratchet_core/split"]
fixture = ["ratchet_core/fixture"]

[dependencies]
ratchet_core = { version = "1.0.3", path = "../ratchet_core" }
ratchet_ext = { version = "1.0.3", path = "../ratchet_ext" }
ratchet_deflate = { version = "1.0.3", path = "../ratchet_deflate", optional = true }
ratchet_core = { workspace = true }
ratchet_ext = { workspace = true }
ratchet_deflate = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
log = { workspace = true }

Expand Down
Loading