Commit graph

11 commits

Author SHA1 Message Date
Emmanuel Gil Peyrot
714d850e69 Remove the -rs suffix of jid, minidom and xmpp
We know those are Rust libraries, no need to add it to the path.  This
synchronises their directory with the crate name, hopefully reducing
confusion.
2020-06-22 02:17:32 +02:00
fa8b9ed199 minidom: rustfmt
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
f151306fbe minidom: forcing a namespace on Element. Stop requiring prefixes.
Below is what I think I did.

A few changes:
- Change prefixes to be something less important in the API.
- Rework the Element struct to force a namespace. In XMPP everything is
  namespaced.
- Remove parent ref on what was previously NamespaceSet and is now
  Prefixes.

More specifically this means `Element::new` has changed to require
`Element`'s new new properties as parameters. `Element::builder` and
`Element::bare` now require a namespace unconditionally.
`Element::prefix` has been removed.

This new API is based on the fact that prefixes are non-essential
(really just an implementation detail) and shouldn't be visible to the
user. It is possible nonetheless to set custom prefixes for
compatibility reasons with `ElementBuilder::prefix`. **A prefix is
firstly mapped to a namespace, and then attached to an element**, there
cannot be a prefix without a namespace.

Prefix inheritance is used if possible but for the case with no
prefix ("xmlns") to be reused, we only check custom prefixes declared on
the tag itself and not ascendants. If it's already used then we generate
prefixes (ns0, ns1, ..) checking on what has been declared on all
ascendants (plus of course those already set on the current tag).

Example API:

```rust
let mut elem = ElementBuilder("stream", "http://etherx.jabber.org/streams")
  .prefix(Some(String::from("stream")), "http://etherx.jabber.org/streams)
  .prefix(None, "jabber:client")
  .attr(..)
  .build();

assert_eq!(elem.ns(), String::from("http://etherx.jabber.org/streams"));
```

See also the few tests added in src/tests.

TODO: Fix inconsistencies wrt. "prefix:name" format provided as a name
when creating an Element with `Element::new` or `Element::bare`.
`Element::builder` already handles this as it should, splitting name and
prefix.
TODO: Change `Element::name` method to `Element::local_name` to make it
more explicit.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
5e7701f334
minidom: Remove remaining Comment bits in node
They were hidden behind the flag and not showing up in tests.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-26 23:21:50 +01:00
9511247d2f minidom: add license headers
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 00:52:26 +01:00
c9e6e3d095 minidom: Handle Node::Comment in PartialEq
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-12-08 11:03:01 +00:00
1c5551a917
minidom: Implement PartialEq manually for Node and Element
Move the NamespaceAwareCompare implementation from xmpp-parsers as Node
and Element's PartialEq implementation. Thanks Astro!

It's a lot more useful in tests to use `assert_eq!` than `assert!`, so
we get both items compared (left and right) instead of a "it failed."
message.

This "breaks" comparison for these two structs in the sense that it is
not strict object comparison anymore but it ensures that namespaces are
all present in the compared objects.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-29 16:02:23 +01:00
276dc4fcb2
minidom: Fix code style
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-06 03:51:58 +01:00
Emmanuel Gil Peyrot
877d5c21da minidom: Add a blanket impl for From<Into<Element>> for Node. 2019-11-03 18:49:11 +01:00
a104ebc3f6
Rustfmt pass, and rustfmt --check in CI"
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-10-23 01:36:02 +02:00
57b2c6a135
Prepare for merge: Move all minidom-rs files into minidom-rs/
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-10-18 14:27:53 +02:00
Renamed from src/node.rs (Browse further)