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

🚸 zv: Make signature parameter generic #416

Merged
merged 2 commits into from
Jul 29, 2023
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
2 changes: 1 addition & 1 deletion zbus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zbus"
version = "4.0.0"
authors = ["Zeeshan Ali Khan <[email protected]>"]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "API for D-Bus communication"
Expand Down
1 change: 0 additions & 1 deletion zbus/src/match_rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub use builder::Builder;
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # use zbus::MatchRule;
/// use std::convert::TryFrom;
///
/// // Let's take the most typical example of match rule to subscribe to properties' changes:
/// let rule = MatchRule::builder()
Expand Down
2 changes: 1 addition & 1 deletion zbus_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
"Marc-André Lureau <[email protected]>",
"Zeeshan Ali Khan <[email protected]>",
]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "proc-macros for zbus"
Expand Down
2 changes: 1 addition & 1 deletion zbus_macros/src/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub fn expand(args: AttributeArgs, mut input: ItemImpl) -> syn::Result<TokenStre
p.ty = Some(get_property_type(output)?);
p.read = true;
let inner = if is_fallible_property {
quote!(self.#ident()#method_await#handle_fallible_property)
quote!(self.#ident() #method_await #handle_fallible_property)
} else {
quote!(::std::result::Result::Ok(
::std::convert::Into::into(
Expand Down
8 changes: 4 additions & 4 deletions zbus_macros/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ fn gen_proxy_method_call(
if let Some(proxy_name) = proxy_object {
let proxy = Ident::new(&proxy_name, Span::call_site());
let signature = quote! {
fn #method#ty_generics(#inputs) -> #zbus::Result<#proxy<'c>>
fn #method #ty_generics(#inputs) -> #zbus::Result<#proxy<'c>>
#where_clause
};

Expand Down Expand Up @@ -602,7 +602,7 @@ fn gen_proxy_method_call(

let output = &m.sig.output;
let signature = quote! {
fn #method#ty_generics(#inputs) #output
fn #method #ty_generics(#inputs) #output
#where_clause
};

Expand Down Expand Up @@ -736,7 +736,7 @@ fn gen_proxy_property(
);
quote! {
#[doc = #gen_doc]
pub #usage fn #receive#ty_generics(
pub #usage fn #receive #ty_generics(
&self
) -> #prop_stream<'c, <#ret_type as #zbus::ResultAdapter>::Ok>
#where_clause
Expand Down Expand Up @@ -1001,7 +1001,7 @@ fn gen_proxy_signal(
quote! {
impl #signal_name_ident {
/// Retrieve the signal arguments.
pub fn args#ty_generics(&'s self) -> #zbus::Result<#signal_args #ty_generics>
pub fn args #ty_generics(&'s self) -> #zbus::Result<#signal_args #ty_generics>
#where_clause
{
::std::convert::TryFrom::try_from(&**self)
Expand Down
2 changes: 1 addition & 1 deletion zbus_names/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zbus_names"
version = "3.0.0"
authors = ["Zeeshan Ali Khan <[email protected]>"]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "A collection of D-Bus bus names types"
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/bus_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::BusName;
///
/// // Valid well-known names.
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/error_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::ErrorName;
///
/// // Valid error names.
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/interface_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::InterfaceName;
///
/// // Valid interface names.
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/member_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::MemberName;
///
/// // Valid member names.
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/unique_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::UniqueName;
///
/// // Valid unique names.
Expand Down
1 change: 0 additions & 1 deletion zbus_names/src/well_known_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use zvariant::{NoneValue, OwnedValue, Str, Type, Value};
/// # Examples
///
/// ```
/// use core::convert::TryFrom;
/// use zbus_names::WellKnownName;
///
/// // Valid well-known names.
Expand Down
2 changes: 1 addition & 1 deletion zbus_polkit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zbus_polkit"
version = "3.0.1"
authors = ["Marc-André Lureau <[email protected]>"]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "PolicyKit binding"
Expand Down
2 changes: 1 addition & 1 deletion zbus_xmlgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
"Tim Small <[email protected]>",
"Zeeshan Ali Khan <[email protected]>",
]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "D-Bus XML interface code generator"
Expand Down
2 changes: 1 addition & 1 deletion zvariant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zvariant"
version = "4.0.0"
authors = ["Zeeshan Ali Khan <[email protected]>"]
edition = "2018"
edition = "2021"
rust-version = "1.64"

description = "D-Bus & GVariant encoding & decoding"
Expand Down
2 changes: 1 addition & 1 deletion zvariant/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "zvariant-fuzz"
version = "0.0.0"
publish = false
edition = "2018"
edition = "2021"

[package.metadata]
cargo-fuzz = true
Expand Down
17 changes: 11 additions & 6 deletions zvariant/src/dbus/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ where
/// Create a Deserializer struct instance.
///
/// On Windows, there is no `fds` argument.
pub fn new<'r: 'de>(
pub fn new<'r: 'de, S>(
bytes: &'r [u8],
#[cfg(unix)] fds: Option<&'f [RawFd]>,
signature: &Signature<'sig>,
signature: S,
ctxt: EncodingContext<B>,
) -> Self {
) -> Result<Self>
where
S: TryInto<Signature<'sig>>,
S::Error: Into<Error>,
{
assert_eq!(ctxt.format(), EncodingFormat::DBus);

let sig_parser = SignatureParser::new(signature.clone());
Self(crate::DeserializerCommon {
let signature = signature.try_into().map_err(Into::into)?;
let sig_parser = SignatureParser::new(signature);
Ok(Self(crate::DeserializerCommon {
ctxt,
sig_parser,
bytes,
Expand All @@ -49,7 +54,7 @@ where
pos: 0,
container_depths: Default::default(),
b: PhantomData,
})
}))
}
}

Expand Down
17 changes: 11 additions & 6 deletions zvariant/src/dbus/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@ where
/// Create a D-Bus Serializer struct instance.
///
/// On Windows, there is no `fds` argument.
pub fn new<'w: 'ser, 'f: 'ser>(
signature: &Signature<'sig>,
pub fn new<'w: 'ser, 'f: 'ser, S>(
signature: S,
writer: &'w mut W,
#[cfg(unix)] fds: &'f mut Vec<RawFd>,
ctxt: EncodingContext<B>,
) -> Self {
) -> Result<Self>
where
S: TryInto<Signature<'sig>>,
S::Error: Into<Error>,
{
assert_eq!(ctxt.format(), EncodingFormat::DBus);

let sig_parser = SignatureParser::new(signature.clone());
Self(crate::SerializerCommon {
let signature = signature.try_into().map_err(Into::into)?;
let sig_parser = SignatureParser::new(signature);
Ok(Self(crate::SerializerCommon {
ctxt,
sig_parser,
writer,
Expand All @@ -50,7 +55,7 @@ where
value_sign: None,
container_depths: Default::default(),
b: PhantomData,
})
}))
}
}

Expand Down
Loading