diff options
author | cel 🌸 <cel@blos.sm> | 2024-06-29 17:06:08 +0100 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2024-06-29 17:06:08 +0100 |
commit | 6b471061157ee1873d7ac4f3e30cd501d27dcb5a (patch) | |
tree | 8187081b398c715e72c461682d62db1eb428a39f /src/element.rs | |
parent | 1f0103cbecc6a4dfe3f34fb6441d4d491b385142 (diff) | |
download | peanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.tar.gz peanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.tar.bz2 peanuts-6b471061157ee1873d7ac4f3e30cd501d27dcb5a.zip |
Diffstat (limited to 'src/element.rs')
-rw-r--r-- | src/element.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/element.rs b/src/element.rs index 4dcb616..35d73a3 100644 --- a/src/element.rs +++ b/src/element.rs @@ -9,7 +9,7 @@ pub struct Namespace { namespace: String, } -// names are qualified, they contain the namespace +// names are qualified, they contain a reference to the namespace (held within the reader/writer) pub struct Name { namespace: String, name: String, @@ -22,27 +22,27 @@ pub enum Node { // should this be a trait? pub struct Element { - name: Name, + pub name: Name, // namespace: Name, // each element once created contains the qualified namespace information for that element // the name contains the qualified namespace so this is unnecessary // namespace: String, // hashmap of explicit namespace declarations on the element itself only // possibly not needed as can be calculated at write time depending on context and qualified namespace, and for reading, element validity and namespaces are kept track of by the reader. - namespaces: HashMap<Option<String>, String>, + pub namespace_decl: HashMap<Option<String>, String>, // attributes can be in a different namespace than the element. how to make sure they are valid? // maybe include the namespace instead of or with the prefix // you can calculate the prefix from the namespaced name and the current writer context // you can validate the prefix and calculate the namespace from the current reader context // this results in readers and writers being able to return qualification errors as they aren't able to create elements until every part is qualified. - attributes: HashMap<Name, String>, - children: Option<Vec<Node>>, + pub attributes: HashMap<Name, String>, + pub children: Option<Vec<Node>>, } // example of deriving an element: // #[derive(XMLWrite, XMLRead)] -// #[peanuts(namespace = "jabber:client", namespace:stream = "http://etherx.jabber.org/streams", name = "stream:stream")] +// #[peanuts(xmlns = "jabber:client", xmlns:stream = "http://etherx.jabber.org/streams", prefix = "stream")] // pub struct Stream { // from: JID, // id: String, |