A type-safe Rust XMPP library.
Find a file
Maxime “pep” Buquet 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
jid-rs jid: 0.9.0 release 2020-02-15 02:27:26 +01:00
minidom-rs minidom: forcing a namespace on Element. Stop requiring prefixes. 2020-04-21 22:23:36 +02:00
tokio-xmpp tokio-xmpp: doc 2020-03-16 00:34:46 +01:00
xmpp-parsers parsers: Fix jingle and jingle_rtp test_size for 32bit 2020-04-05 19:05:12 +02:00
xmpp-rs xmpp-rs: add env_logger in example 2020-03-13 23:25:06 +01:00
.gitignore Hello world! 2019-03-21 18:43:27 +01:00
.gitlab-ci.yml CI: Remove build stage 2020-04-05 15:05:16 +02:00
Cargo.toml Create Cargo.toml workspace file. Add patch directives to override path 2019-10-19 17:57:43 +02:00
LICENSE Readd global LICENSE file 2020-02-25 22:13:34 +01:00