18 releases

0.6.3 Jul 13, 2024
0.6.2 Jan 28, 2024
0.6.1 Sep 21, 2023
0.6.0 Jul 28, 2023
0.3.1 Feb 19, 2022

#1287 in Network programming

Download history 292/week @ 2024-08-07 355/week @ 2024-08-14 443/week @ 2024-08-21 667/week @ 2024-08-28 881/week @ 2024-09-04 962/week @ 2024-09-11 855/week @ 2024-09-18 1054/week @ 2024-09-25 842/week @ 2024-10-02 767/week @ 2024-10-09 871/week @ 2024-10-16 1066/week @ 2024-10-23 890/week @ 2024-10-30 705/week @ 2024-11-06 1088/week @ 2024-11-13 1109/week @ 2024-11-20

4,040 downloads per month
Used in 3 crates

MIT/Apache

145KB
4K SLoC

DXR: declarative XML-RPC

crates.io crates.io crates.io docs.rs

The dxr project provides crates for writing XML-RPC API clients and servers in Rust. The goal is to match the XML-RPC Specification -- even though some parts of it are under-specified -- and provide optional support for some common non-standard extensions.

Features

  • (de)serialization support for converting XML-RPC XML strings into strongly-typed Rust values
  • conversion traits between XML-RPC values and Rust primitives, arrays, slices, byte arrays, tuples, hashmaps, and custom structs (via derive macros)
  • built-in XML-escaping and un-escaping of string arguments
  • built-in date & time parsing for the dateTime.iso8861 value type
  • built-in base64 en- and decoding of byte vectors for the base64 type
  • optional support for (non-standard) <i8> (64-bit unsigned integer) and <nil/> values
  • support for arbitrary method call argument types without needing to convert values first (for up to 8 arguments; support for more could be implemented, if needed)
  • basic support for both XML-RPC clients (with reqwest) and servers (with axum)

All conversion methods (both between Rust XML-RPC values and XML strings, and between Rust primitives and Rust XML-RPC values) are extensively checked for correctness by unit tests and property-based tests using quickcheck.

Limitations

Only valid UTF-8 is currently supported in both XML-RPC requests and responses. Support for other encodings can be handled manually by implementing a custom client or server which handles other encodings transparently.

Components

  • dxr: implementation of XML-RPC types, conversion traits between XML-RPC types and Rust types, and (de)serialization implementations for converting between XML strings and XML-RPC values
  • dxr_derive: TryFromDXR and TryToDxr derive macros for custom data types
  • dxr_client: XML-RPC client implementation using reqwest
  • dxr_server: generic XML-RPC server functionality

Why another crate for XML-RPC?

Searching for xml-rpc on crates.io yields a few results, but they all did not fit my use case, or were very hard to use. Either they didn't support implementing both clients and servers, or no easy conversion methods from Rust types to XML-RPC types was available. And none of the crates supports (de)serializing both Rust types and custom user-defined types by using derive macros.

Goals

Because of this state of the XML-RPC crate ecosystem in Rust, the defining purpose of the dxr crate is that it should be opinionated, but also very easy to use, for implementing both XML-RPC clients and servers, with first-class support for (de)serializing custom types, in addition to built-in support for transparently converting Rust primitives to XML-RPC values.

Additionally, the crate is built on top of best-in-class (in my opinion) libraries for (de)serializing XML (quick-xml), HTTP client side (reqwest), HTTP server side (axum).

Dependencies

~2.7–4MB
~69K SLoC