zbus/blocking/proxy/
builder.rs1use zbus_names::{BusName, InterfaceName};
2use zvariant::ObjectPath;
3
4use crate::{blocking::Connection, proxy::CacheProperties, utils::block_on, Error, Result};
5
6pub use crate::proxy::Defaults;
7
8#[derive(Debug, Clone)]
10pub struct Builder<'a, T = ()>(crate::proxy::Builder<'a, T>);
11
12impl<'a, T> Builder<'a, T> {
13 pub fn destination<D>(self, destination: D) -> Result<Self>
15 where
16 D: TryInto<BusName<'a>>,
17 D::Error: Into<Error>,
18 {
19 crate::proxy::Builder::destination(self.0, destination).map(Self)
20 }
21
22 pub fn path<P>(self, path: P) -> Result<Self>
24 where
25 P: TryInto<ObjectPath<'a>>,
26 P::Error: Into<Error>,
27 {
28 crate::proxy::Builder::path(self.0, path).map(Self)
29 }
30
31 pub fn interface<I>(self, interface: I) -> Result<Self>
33 where
34 I: TryInto<InterfaceName<'a>>,
35 I::Error: Into<Error>,
36 {
37 crate::proxy::Builder::interface(self.0, interface).map(Self)
38 }
39
40 #[must_use]
42 pub fn cache_properties(self, cache: CacheProperties) -> Self {
43 Self(self.0.cache_properties(cache))
44 }
45
46 #[must_use]
48 pub fn uncached_properties(self, properties: &[&'a str]) -> Self {
49 Self(self.0.uncached_properties(properties))
50 }
51
52 pub fn build(self) -> Result<T>
58 where
59 T: From<crate::Proxy<'a>>,
60 {
61 block_on(self.0.build())
62 }
63}
64
65impl<T> Builder<'_, T>
66where
67 T: Defaults,
68{
69 #[must_use]
71 pub fn new(conn: &Connection) -> Self {
72 Self(crate::proxy::Builder::new(&conn.clone().into()))
73 }
74}