pub struct Builder { /* private fields */ }Expand description
Reads interface files and generates bindings for the interfaces in them.
§Examples
tokio_dbus_codegen::Builder::new()
.file("interfaces/org.kde.StatusNotifierItem.xml")
.file("interfaces/com.canonical.dbusmenu.xml")
.server("org.kde.StatusNotifierItem")
.server("com.canonical.dbusmenu")
.client("org.kde.StatusNotifierWatcher")
.generate("systray.rs")?;Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty builder.
Examples found in repository?
examples/dump.rs (line 11)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let mut args = std::env::args().skip(1);
9
10 let file = args.next().ok_or("Usage: dump <file.xml> <interface>...")?;
11 let mut builder = tokio_dbus_codegen::Builder::new().file(file);
12
13 for name in args {
14 builder = builder.both(name);
15 }
16
17 print!("{}", builder.to_string()?);
18 Ok(())
19}Sourcepub fn file(self, path: impl AsRef<Path>) -> Self
pub fn file(self, path: impl AsRef<Path>) -> Self
Read an interface file.
Every interface in the file becomes available to client(),
server() and both(), including the ones in child nodes.
Examples found in repository?
examples/dump.rs (line 11)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let mut args = std::env::args().skip(1);
9
10 let file = args.next().ok_or("Usage: dump <file.xml> <interface>...")?;
11 let mut builder = tokio_dbus_codegen::Builder::new().file(file);
12
13 for name in args {
14 builder = builder.both(name);
15 }
16
17 print!("{}", builder.to_string()?);
18 Ok(())
19}Sourcepub fn client(self, interface: impl AsRef<str>) -> Self
pub fn client(self, interface: impl AsRef<str>) -> Self
Generate an asynchronous client for the named interface.
Sourcepub fn server(self, interface: impl AsRef<str>) -> Self
pub fn server(self, interface: impl AsRef<str>) -> Self
Generate a server trait and dispatcher for the named interface.
Sourcepub fn both(self, interface: impl AsRef<str>) -> Self
pub fn both(self, interface: impl AsRef<str>) -> Self
Generate both a client and a server for the named interface.
Examples found in repository?
examples/dump.rs (line 14)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let mut args = std::env::args().skip(1);
9
10 let file = args.next().ok_or("Usage: dump <file.xml> <interface>...")?;
11 let mut builder = tokio_dbus_codegen::Builder::new().file(file);
12
13 for name in args {
14 builder = builder.both(name);
15 }
16
17 print!("{}", builder.to_string()?);
18 Ok(())
19}Sourcepub fn generate(self, name: impl AsRef<Path>) -> Result<PathBuf>
pub fn generate(self, name: impl AsRef<Path>) -> Result<PathBuf>
Generate into $OUT_DIR/<name>, which is where a build script should
put it.
This also emits a cargo::rerun-if-changed line for every interface file
which was read.
Sourcepub fn to_string(&self) -> Result<String>
pub fn to_string(&self) -> Result<String>
Generate the bindings and return them as a string.
This is what generate() and write_to() use, and is useful for
inspecting the output in a test.
Examples found in repository?
examples/dump.rs (line 17)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let mut args = std::env::args().skip(1);
9
10 let file = args.next().ok_or("Usage: dump <file.xml> <interface>...")?;
11 let mut builder = tokio_dbus_codegen::Builder::new().file(file);
12
13 for name in args {
14 builder = builder.both(name);
15 }
16
17 print!("{}", builder.to_string()?);
18 Ok(())
19}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more