nerdtalk is an XML-RPC implementation in pure Nim.
❗ nerdtalk is still very much in development so use this
library at your own discretion.
Here is an example nerdtalk using the xmlRpcSpec macro:
import nerdtalk
xmlRpcSpec:
name: "download_list"
name: "d.name"
params:
hash: string
when isMainModule:
echo download_list()
echo d_name("ABDCEFGH1234567890")For deserialization (unmarshalling):
import nerdtalk
# ...
socket.read(buffer, 1023)
var response = :!bufferDocumentation can be generated with:
nimble docs
In order to increase ease of use, nerdtalk maps Nim's type system
to XML-RPC "types".
An int maps to <iN> where N is the bit width of the integer on the host platform
A float maps to <double>
A string, char, and cstring maps to <string>
A DateTime object maps to <datetime.iso8601>
A bool maps to <boolean>
An object maps to <struct>
An object marked with {.xrarray.} maps to <array>
Sequences and arrays map to <array>
Any type T can map to <base64> iff T implements $
-
Why
{.xarray.}?XML-RPC allows different types within
<array>. The{.xarray.}allows users to do so with custom object types since sequences and arrays require all elements to be of the same type.
- Add support for deserialization between
XmlRpcTypeand user-types a lastd/json - Add more tests for deserialization and exception handling