WIP.
bash
$ sudo dnf copr enable "@varlink/varlink"
$ sudo dnf install fedora-varlink
$ sudo setenforce 0 # needed until systemd is able to create sockets in /run
$ sudo systemctl enable --now org.varlink.resolver.socket
$ varlink help
``
$ cargo run --example validate examples/io_systemd_network/io.systemd.network.varlink
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running
target/debug/examples/validate examples/iosystemdnetwork/io.systemd.network.varlink`
Syntax check passed!
interface io.systemd.network type Netdev (ifindex: int, ifname: string) type NetdevInfo (ifindex: int, ifname: string) method Info(ifindex: int) -> (info: NetdevInfo) method List() -> (netdevs: Netdev[]) error InvalidParameter (field: string) error UnknownNetworkDevice () ```
``rust
$ cargo run --example varlink-generator examples/io_systemd_network/io.systemd.network.varlink
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running
target/debug/examples/varlink-generator examples/iosystemdnetwork/io.systemd.network.varlink`
// This file is automatically generated by the varlink rust generator
use std::result::Result;
use std::convert::From;
use varlink; use serde_json;
pub struct Netdev {
pub ifindex: Option
pub struct NetdevInfo {
pub ifindex: Option
pub struct InfoReply {
pub info: Option
pub struct InfoArgs {
pub ifindex: Option
pub struct ListReply {
pub netdevs: Option
pub struct UnknownErrorArgs {
pub text: Option
pub enum Error {
UnknownError(Option
bash
$ cargo run --example server
and test from a new shell
```javascript $ varlink help tcp:127.0.0.1:12345/org.varlink.service
interface org.varlink.service
method GetInfo() -> ( vendor: string, product: string, version: string, url: string, interfaces: string[] )
method GetInterfaceDescription(interface: string) -> (description: string)
error InterfaceNotFound (interface: string)
error MethodNotFound (method: string)
error MethodNotImplemented (method: string)
error InvalidParameter (parameter: string) ```
```javascript $ varlink help tcp:127.0.0.1:12345/io.systemd.network
interface io.systemd.network
type NetdevInfo (ifindex: int, ifname: string)
type Netdev (ifindex: int, ifname: string)
method Info(ifindex: int) -> (info: NetdevInfo)
method List() -> (netdevs: Netdev[])
error UnknownNetworkDevice ()
error InvalidParameter (field: string) ```
javascript
$ varlink call tcp:127.0.0.1:12345/io.systemd.network.List
{
"netdevs": [
{
"ifindex": 1,
"ifname": "lo"
},
{
"ifindex": 2,
"ifname": "eth0"
}
]
}