Rebus.Introspection (rebus v0.4.0)

View Source

Generates D-Bus introspection XML, the document that org.freedesktop.DBus.Introspectable.Introspect returns.

to_xml/1 renders a Rebus.Introspection.Node in the format the D-Bus specification describes. Rebus only generates introspection XML; it does not parse it.

Example

calculator =
  Rebus.Interface.new!("org.example.Calculator",
    methods: [{"Add", in: [a: "i", b: "i"], out: [sum: "i"]}]
  )

%Rebus.Introspection.Node{interfaces: [calculator], children: ["History"]}
|> Rebus.Introspection.to_xml()
|> IO.iodata_to_binary()

returns

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.example.Calculator">
    <method name="Add">
      <arg name="a" type="i" direction="in"/>
      <arg name="b" type="i" direction="in"/>
      <arg name="sum" type="i" direction="out"/>
    </method>
  </interface>
  <node name="History"/>
</node>

Summary

Functions

Renders a node as introspection XML.

Functions

to_xml(node)

@spec to_xml(Rebus.Introspection.Node.t()) :: iodata()

Renders a node as introspection XML.

Interfaces appear in the order given. Within an interface, annotations come first, then methods, signals and properties, each sorted by name. Child nodes come last, sorted and without duplicates. Every attribute value is escaped.