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

Upgrade deps #56

Merged
merged 3 commits into from
Sep 17, 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
10 changes: 9 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@ jobs:
path: ~/.cargo/bin
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-tarpaulin

- name: Run tests
- name: Run tests (tokio)
uses: actions-rs/cargo@v1
timeout-minutes: 40
with:
command: test
args: --all --no-fail-fast --features=ntex/tokio -- --nocapture

- name: Run tests (compio)
uses: actions-rs/cargo@v1
timeout-minutes: 40
if: matrix.version != '1.75.0'
with:
command: test
args: --all --no-fail-fast --features=ntex/compio -- --nocapture

- name: Install tarpaulin
if: matrix.version == '1.75.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all --no-fail-fast --features=ntex/tokio -- --nocapture
args: --all --no-fail-fast --features=ntex/compio -- --nocapture

- name: Clear the cargo caches
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features=ntex/tokio -- --nocapture
args: --all --features=ntex/compio -- --nocapture
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes

## [3.1.0] - 2024-0x-xx
## [3.0.4] - 2024-09-17

* Use derive_more 1.0

Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-amqp"
version = "3.1.0"
version = "3.0.4"
authors = ["ntex contributors <[email protected]>"]
description = "AMQP 1.0 Client/Server framework"
documentation = "https://docs.rs/ntex-amqp"
Expand Down Expand Up @@ -38,7 +38,6 @@ derive_more = { version = "1", features = ["display", "from"] }
[dev-dependencies]
env_logger = "0.11"
rand = "0.8"
ntex = { version = "2", features = ["tokio"] }
ntex-amqp = { path = ".", features = ["frame-trace"] }

[patch.crates-io]
Expand Down
14 changes: 7 additions & 7 deletions codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ rust-version = "1.75"
ntex-bytes = "0.1"
ntex-codec = "0.6"
byteorder = "1"
fxhash = "0.2.1"
fxhash = "0.2"
chrono = { version = "0.4", default-features = false }
derive_more = { version = "1", features = ["display", "from"] }
ordered-float = "4.2"
uuid = { version = "1", features = ["v4"] }

[build-dependencies]
handlebars = { version = "0.27", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
lazy_static = { version = "1.0", optional = true }
regex = { version = "1.5", optional = true }
handlebars = { version = "6", optional = true }
serde = { version = "1", optional = true }
serde_derive = { version = "1", optional = true }
serde_json = { version = "1", optional = true }
lazy_static = { version = "1", optional = true }
regex = { version = "1", optional = true }

[features]
default = []
Expand Down
27 changes: 20 additions & 7 deletions codec/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ fn main() {

#[cfg(feature = "from-spec")]
fn generate_from_spec() {
use handlebars::{Handlebars, Helper, RenderContext, RenderError};
use handlebars::{
Context, Handlebars, Helper, Output, RenderContext, RenderError, RenderErrorReason,
};
use std::env;
use std::fs::File;
use std::io::Write;
Expand All @@ -47,14 +49,25 @@ fn generate_from_spec() {
codegen.register_helper(
"snake",
Box::new(
|h: &Helper, _: &Handlebars, rc: &mut RenderContext| -> Result<(), RenderError> {
let value = h
.param(0)
.ok_or_else(|| RenderError::new("Param not found for helper \"snake\""))?;
|h: &Helper,
_: &Handlebars,
_: &Context,
_rc: &mut RenderContext,
out: &mut dyn Output|
-> Result<(), RenderError> {
let value = h.param(0).ok_or_else(|| {
RenderErrorReason::ParamNotFoundForName(
"Param not found for helper",
"snake".to_string(),
)
})?;
let param = value.value().as_str().ok_or_else(|| {
RenderError::new("Non-string param given to helper \"snake\"")
RenderErrorReason::ParamNotFoundForName(
"Param not found for helper",
"snake".to_string(),
)
})?;
rc.writer.write_all(codegen::snake_case(param).as_bytes())?;
out.write(&codegen::snake_case(param))?;
Ok(())
},
),
Expand Down
114 changes: 57 additions & 57 deletions codec/src/protocol/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,63 @@ impl Encode for Frame {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DeliveryState {
Received(Received),
Accepted(Accepted),
Rejected(Rejected),
Released(Released),
Modified(Modified),
}
impl DecodeFormatted for DeliveryState {
fn decode_with_format(input: &mut Bytes, fmt: u8) -> Result<Self, AmqpParseError> {
validate_code!(fmt, codec::FORMATCODE_DESCRIBED);
let descriptor = Descriptor::decode(input)?;
match descriptor {
Descriptor::Ulong(35) => decode_received_inner(input).map(DeliveryState::Received),
Descriptor::Ulong(36) => decode_accepted_inner(input).map(DeliveryState::Accepted),
Descriptor::Ulong(37) => decode_rejected_inner(input).map(DeliveryState::Rejected),
Descriptor::Ulong(38) => decode_released_inner(input).map(DeliveryState::Released),
Descriptor::Ulong(39) => decode_modified_inner(input).map(DeliveryState::Modified),
Descriptor::Symbol(ref a) if a.as_str() == "amqp:received:list" => {
decode_received_inner(input).map(DeliveryState::Received)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:accepted:list" => {
decode_accepted_inner(input).map(DeliveryState::Accepted)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:rejected:list" => {
decode_rejected_inner(input).map(DeliveryState::Rejected)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:released:list" => {
decode_released_inner(input).map(DeliveryState::Released)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:modified:list" => {
decode_modified_inner(input).map(DeliveryState::Modified)
}
_ => Err(AmqpParseError::InvalidDescriptor(Box::new(descriptor))),
}
}
}
impl Encode for DeliveryState {
fn encoded_size(&self) -> usize {
match *self {
DeliveryState::Received(ref v) => encoded_size_received_inner(v),
DeliveryState::Accepted(ref v) => encoded_size_accepted_inner(v),
DeliveryState::Rejected(ref v) => encoded_size_rejected_inner(v),
DeliveryState::Released(ref v) => encoded_size_released_inner(v),
DeliveryState::Modified(ref v) => encoded_size_modified_inner(v),
}
}
fn encode(&self, buf: &mut BytesMut) {
match *self {
DeliveryState::Received(ref v) => encode_received_inner(v, buf),
DeliveryState::Accepted(ref v) => encode_accepted_inner(v, buf),
DeliveryState::Rejected(ref v) => encode_rejected_inner(v, buf),
DeliveryState::Released(ref v) => encode_released_inner(v, buf),
DeliveryState::Modified(ref v) => encode_modified_inner(v, buf),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Section {
Header(Header),
DeliveryAnnotations(DeliveryAnnotations),
Expand Down Expand Up @@ -203,63 +260,6 @@ impl Encode for Section {
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum DeliveryState {
Received(Received),
Accepted(Accepted),
Rejected(Rejected),
Released(Released),
Modified(Modified),
}
impl DecodeFormatted for DeliveryState {
fn decode_with_format(input: &mut Bytes, fmt: u8) -> Result<Self, AmqpParseError> {
validate_code!(fmt, codec::FORMATCODE_DESCRIBED);
let descriptor = Descriptor::decode(input)?;
match descriptor {
Descriptor::Ulong(35) => decode_received_inner(input).map(DeliveryState::Received),
Descriptor::Ulong(36) => decode_accepted_inner(input).map(DeliveryState::Accepted),
Descriptor::Ulong(37) => decode_rejected_inner(input).map(DeliveryState::Rejected),
Descriptor::Ulong(38) => decode_released_inner(input).map(DeliveryState::Released),
Descriptor::Ulong(39) => decode_modified_inner(input).map(DeliveryState::Modified),
Descriptor::Symbol(ref a) if a.as_str() == "amqp:received:list" => {
decode_received_inner(input).map(DeliveryState::Received)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:accepted:list" => {
decode_accepted_inner(input).map(DeliveryState::Accepted)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:rejected:list" => {
decode_rejected_inner(input).map(DeliveryState::Rejected)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:released:list" => {
decode_released_inner(input).map(DeliveryState::Released)
}
Descriptor::Symbol(ref a) if a.as_str() == "amqp:modified:list" => {
decode_modified_inner(input).map(DeliveryState::Modified)
}
_ => Err(AmqpParseError::InvalidDescriptor(Box::new(descriptor))),
}
}
}
impl Encode for DeliveryState {
fn encoded_size(&self) -> usize {
match *self {
DeliveryState::Received(ref v) => encoded_size_received_inner(v),
DeliveryState::Accepted(ref v) => encoded_size_accepted_inner(v),
DeliveryState::Rejected(ref v) => encoded_size_rejected_inner(v),
DeliveryState::Released(ref v) => encoded_size_released_inner(v),
DeliveryState::Modified(ref v) => encoded_size_modified_inner(v),
}
}
fn encode(&self, buf: &mut BytesMut) {
match *self {
DeliveryState::Received(ref v) => encode_received_inner(v, buf),
DeliveryState::Accepted(ref v) => encode_accepted_inner(v, buf),
DeliveryState::Rejected(ref v) => encode_rejected_inner(v, buf),
DeliveryState::Released(ref v) => encode_released_inner(v, buf),
DeliveryState::Modified(ref v) => encode_modified_inner(v, buf),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Outcome {
Accepted(Accepted),
Rejected(Rejected),
Expand Down
Loading