Crate varlink_derive

Crate varlink_derive 

Source
Expand description

Macros for generating modules from a varlink interface definition

This crate provides two procedural macros for generating a Rust module out of an interface definition:

  • The varlink! macro takes as argument the interface as a string literal.
  • The varlink_file! macro takes as argument the path to the varlink interface definition relative to the directory containing the manifest of your package.

They have the drawback that most IDEs don’t execute this and thus offer no code completion.

§Examples

use varlink_derive;
extern crate serde_derive;

varlink_derive::varlink!(org_example_ping, r#"
# Example service
interface org.example.ping

# Returns the same string
method Ping(ping: string) -> (pong: string)
"#);

use org_example_ping::VarlinkClientInterface;
/* ... */
use varlink_derive;
extern crate serde_derive;

varlink_derive::varlink_file!(
   org_example_network,
   "../examples/example/src/org.example.network.varlink"
);

use org_example_network::VarlinkClientInterface;
/* ... */

Macros§

varlink
Generates a module from a varlink interface definition
varlink_async
Generates a module with async client support from a varlink interface definition
varlink_file
Generates a module from a varlink interface definition file
varlink_file_async
Generates a module with async client support from a varlink interface definition file