diff --git a/Cargo.toml b/Cargo.toml index e17f4ca..85fea1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,18 +25,18 @@ unix-seqpacket = ["tokio-seqpacket"] unix-stream = ["tokio/net"] [dependencies] -byteorder = "1.3.4" -filedesc = { version = "0.6.0" } -tokio = { version = "1.0.0", features = ["rt", "sync"] } +byteorder = "1.4.3" +filedesc = { version = "0.6.1" } +tokio = { version = "1.32.0", features = ["rt", "sync"] } tokio-seqpacket = { version = "0.7.0", optional = true } fizyr-rpc-macros = { version = "=0.6.0", path = "macros", optional = true } [dev-dependencies] -assert2 = "0.3.3" -clap = { version = "3.1.10", features = ["derive"] } -tokio = { version = "1.0.0", features = ["macros"] } +assert2 = "0.3.11" +clap = { version = "4.4.4", features = ["derive"] } +tokio = { version = "1.32.0", features = ["macros"] } fizyr-rpc = { path = ".", features = ["unix-seqpacket", "unix-stream", "tcp"] } -memfile = "0.2.0" +memfile = "0.2.1" [package.metadata.docs.rs] features = ["macros", "tcp", "unix-stream", "unix-seqpacket"] diff --git a/examples/tcp-client.rs b/examples/tcp-client.rs index d6ca27e..9033f34 100644 --- a/examples/tcp-client.rs +++ b/examples/tcp-client.rs @@ -1,7 +1,6 @@ use fizyr_rpc::TcpPeer; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { #[clap(default_value = "localhost:12345")] address: String, diff --git a/examples/tcp-server.rs b/examples/tcp-server.rs index cf34ae0..9a352c3 100644 --- a/examples/tcp-server.rs +++ b/examples/tcp-server.rs @@ -1,7 +1,6 @@ use fizyr_rpc::TcpListener; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { #[clap(default_value = "[::]:12345")] bind: String, diff --git a/examples/unix-seqpacket-client.rs b/examples/unix-seqpacket-client.rs index d2c1b6a..22292e1 100644 --- a/examples/unix-seqpacket-client.rs +++ b/examples/unix-seqpacket-client.rs @@ -3,7 +3,6 @@ use fizyr_rpc::UnixSeqpacketPeer; use std::path::PathBuf; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } diff --git a/examples/unix-seqpacket-server.rs b/examples/unix-seqpacket-server.rs index b7fae98..280174a 100644 --- a/examples/unix-seqpacket-server.rs +++ b/examples/unix-seqpacket-server.rs @@ -2,7 +2,6 @@ use fizyr_rpc::UnixSeqpacketListener; use std::path::PathBuf; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } diff --git a/examples/unix-stream-client.rs b/examples/unix-stream-client.rs index fcd5fbc..0f97961 100644 --- a/examples/unix-stream-client.rs +++ b/examples/unix-stream-client.rs @@ -3,7 +3,6 @@ use fizyr_rpc::UnixStreamPeer; use std::path::PathBuf; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } diff --git a/examples/unix-stream-server.rs b/examples/unix-stream-server.rs index 506c1f5..de76a96 100644 --- a/examples/unix-stream-server.rs +++ b/examples/unix-stream-server.rs @@ -2,7 +2,6 @@ use fizyr_rpc::UnixStreamListener; use std::path::PathBuf; #[derive(clap::Parser)] -#[clap(setting = clap::AppSettings::DeriveDisplayOrder)] struct Options { socket: PathBuf, } diff --git a/macros-tests/Cargo.toml b/macros-tests/Cargo.toml index 3d4a284..01a69d1 100644 --- a/macros-tests/Cargo.toml +++ b/macros-tests/Cargo.toml @@ -6,10 +6,10 @@ publish = [] [dependencies] fizyr-rpc = { path = "..", features = ["macros"]} -serde = { version = "1.0.126", features = ["derive"] } -serde_json = "1.0.64" +serde = { version = "1.0.188", features = ["derive"] } +serde_json = "1.0.107" [dev-dependencies] -assert2 = "0.3.5" +assert2 = "0.3.11" fizyr-rpc = { path = "..", features = ["unix-stream"] } -tokio = { version = "1.0.0", features = ["macros", "net", "rt"] } +tokio = { version = "1.32.0", features = ["macros", "net", "rt"] } diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 8e6ad30..628f5f6 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -16,6 +16,6 @@ edition = "2021" proc_macro = true [dependencies] -syn = { version = "1.0.72", default-features = false, features = ["derive", "parsing", "printing", "proc-macro"] } -proc-macro2 = "1.0.26" -quote = "1.0.9" +syn = { version = "2.0.37", default-features = false, features = ["derive", "parsing", "printing", "proc-macro"] } +proc-macro2 = "1.0.67" +quote = "1.0.33" diff --git a/macros/src/interface/parse.rs b/macros/src/interface/parse.rs index 53a3a3e..9b38be9 100644 --- a/macros/src/interface/parse.rs +++ b/macros/src/interface/parse.rs @@ -366,13 +366,13 @@ pub mod cooked { let mut doc = Vec::new(); for attr in attrs { - if attr.path.is_ident("doc") { - match parse_doc_attr_contents(attr.tokens) { + if attr.path().is_ident("doc") { + match parse_doc_attr_contents(attr) { Ok(x) => doc.push(x), Err(e) => errors.push(e), } } else { - errors.push(syn::Error::new_spanned(attr.path, "unknown attribute")); + errors.push(syn::Error::new_spanned(attr.path(), "unknown attribute")); } } diff --git a/macros/src/util.rs b/macros/src/util.rs index 19ce148..7c37fe6 100644 --- a/macros/src/util.rs +++ b/macros/src/util.rs @@ -36,31 +36,13 @@ pub fn parse_repeated(input: ParseStream) -> syn::Result> { Ok(result) } -/// Helper struct to parse `= T` from a token stream. -struct EqAttrContents { - _eq_token: syn::token::Eq, - value: T, -} - -impl Parse for EqAttrContents { - fn parse(input: ParseStream) -> syn::Result { - Ok(Self { - _eq_token: input.parse()?, - value: input.parse()?, - }) - } -} - -/// Parse the input tokens as `= T`. -/// -/// This is useful for parsing `#[attr = value]` style attributes. -pub fn parse_eq_attr_contents(input: TokenStream) -> syn::Result { - let parsed: EqAttrContents = syn::parse2(input)?; - Ok(parsed.value) -} - /// Parse the string value of a doc attribute. -pub fn parse_doc_attr_contents(input: TokenStream) -> syn::Result> { - let doc: syn::LitStr = parse_eq_attr_contents(input)?; +pub fn parse_doc_attr_contents(attribute: syn::Attribute) -> syn::Result> { + let meta = attribute.meta.require_name_value()?; + let doc = match &meta.value { + syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(value), .. }) => value, + _ => return Err(syn::Error::new_spanned(&meta.value, "expected a string literal")), + }; + Ok(WithSpan::new(doc.span(), doc.value())) }