-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from mercedes-benz/split-xml-mod-into-crate
π Move xml mod into a separate crate, zbus_xml
- Loading branch information
Showing
17 changed files
with
169 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ members = [ | |
"zvariant_derive", | ||
"zvariant_utils", | ||
"zbus_macros", | ||
"zbus_xml", | ||
"zbus_xmlgen", | ||
] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "zbus_xml" | ||
version = "4.0.0" | ||
authors = ["Zeeshan Ali Khan <[email protected]>"] | ||
edition = "2021" | ||
rust-version = "1.64" | ||
|
||
description = "API to handle D-Bus introspection XML" | ||
repository = "https://github.com/dbus2/zbus/" | ||
keywords = ["D-Bus", "DBus", "IPC", "XML"] | ||
license = "MIT" | ||
categories = ["parsing"] | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
zvariant = { path = "../zvariant", version = "4.0.0", default-features = false } | ||
zbus_names = { path = "../zbus_names", version = "3.0" } | ||
quick-xml = { version = "0.27.1", features = ["serialize", "overlapped-lists"] } | ||
static_assertions = "1.1.0" | ||
|
||
[dev-dependencies] | ||
doc-comment = "0.3.3" | ||
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
targets = ["x86_64-unknown-linux-gnu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# zbus_xml | ||
|
||
[![](https://docs.rs/zbus_xml/badge.svg)](https://docs.rs/zbus_xml/) [![](https://img.shields.io/crates/v/zbus_xml)](https://crates.io/crates/zbus_xml) | ||
|
||
API to handle D-Bus introspection XML. | ||
|
||
Thanks to the [`org.freedesktop.DBus.Introspectable`] interface, objects may be introspected at | ||
runtime, returning an XML string that describes the object. | ||
|
||
This crate provides facilities to parse the XML data into more convenient | ||
Rust structures. The XML string may be parsed to a tree with [`Node::from_reader`]. | ||
|
||
**Status:** Stable. | ||
|
||
[`Node::from_reader`]: https://docs.rs/zbus_xml/latest/zbus_xml/struct.Node.html#method.from_reader | ||
[Introspection format]: https://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format | ||
[`org.freedesktop.DBus.Introspectable`]: https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-introspectable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use quick_xml::de::DeError; | ||
use static_assertions::assert_impl_all; | ||
use std::{convert::Infallible, error, fmt}; | ||
use zvariant::Error as VariantError; | ||
|
||
/// The error type for `zbus_names`. | ||
/// | ||
/// The various errors that can be reported by this crate. | ||
#[derive(Clone, Debug)] | ||
#[non_exhaustive] | ||
pub enum Error { | ||
Variant(VariantError), | ||
/// An XML error from quick_xml | ||
QuickXml(DeError), | ||
} | ||
|
||
assert_impl_all!(Error: Send, Sync, Unpin); | ||
|
||
impl PartialEq for Error { | ||
fn eq(&self, other: &Self) -> bool { | ||
match (self, other) { | ||
(Self::Variant(s), Self::Variant(o)) => s == o, | ||
(Self::QuickXml(_), Self::QuickXml(_)) => false, | ||
(_, _) => false, | ||
} | ||
} | ||
} | ||
|
||
impl error::Error for Error { | ||
fn source(&self) -> Option<&(dyn error::Error + 'static)> { | ||
match self { | ||
Error::Variant(e) => Some(e), | ||
Error::QuickXml(e) => Some(e), | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Error::Variant(e) => write!(f, "{e}"), | ||
Error::QuickXml(e) => write!(f, "XML error: {e}"), | ||
} | ||
} | ||
} | ||
|
||
impl From<VariantError> for Error { | ||
fn from(val: VariantError) -> Self { | ||
Error::Variant(val) | ||
} | ||
} | ||
|
||
impl From<DeError> for Error { | ||
fn from(val: DeError) -> Self { | ||
Error::QuickXml(val) | ||
} | ||
} | ||
|
||
impl From<Infallible> for Error { | ||
fn from(i: Infallible) -> Self { | ||
match i {} | ||
} | ||
} | ||
|
||
/// Alias for a `Result` with the error type `zbus_xml::Error`. | ||
pub type Result<T> = std::result::Result<T, Error>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.