Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This is a Rust workspace implementing an asynchronous Varlink IPC library. The a
- **zlink-core**: No-std foundation providing core APIs. Not used directly.
- **zlink-macros**: Contains the attribute and derive macros. Not used directly.
- **zlink-tokio**: Tokio runtime integration and transport implementations. Not used directly.
- **zlink-smol**: smol runtime integration and transport implementations. Not used directly.
- **zlink**: Main unified API crate that re-exports appropriate subcrates based on cargo features.

### Key Components
Expand All @@ -71,7 +72,7 @@ This is a Rust workspace implementing an asynchronous Varlink IPC library. The a

- `idl`: Support for IDL type representations.
- `introspection`: Enable runtime introspection of service interfaces.
- `idl-parse`: Parse Varlink IDL files at runtime (requires `std`).
- `idl-parse`: Parse Varlink IDL at runtime (works in `no_std`).

### Development Patterns
- Uses workspace-level package metadata (edition, rust-version, license, repository)
Expand Down
26 changes: 7 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ applications. zlink makes it easy to implement Varlink services in Rust with:

- **Async-first design**: Built on async/await for efficient concurrent operations.
- **Type safety**: Leverage Rust's type system with derive macros and code generation.
- **Multiple transports**: Unix domain sockets and (upcoming) USB support.
- **Unix domain sockets**: Communicate over Unix domain socket transports.
- **Runtime choice**: Use either the Tokio or smol async runtime.
- **Code generation**: Generate Rust code from Varlink IDL files.

## Project Structure
Expand All @@ -38,6 +39,7 @@ The zlink project consists of several subcrates:
- **[`zlink-core`]**: Core no-std foundation providing essential Varlink types and traits.
- **[`zlink-macros`]**: Contains the attribute and derive macros.
- **[`zlink-tokio`]**: `Tokio`-based transport implementations and runtime integration.
- **[`zlink-smol`]**: `smol`-based transport implementations and runtime integration.
- **[`zlink-codegen`]**: Code generation tool for creating Rust bindings from Varlink IDL files.

## Examples
Expand Down Expand Up @@ -229,6 +231,9 @@ impl Calculator {
> **Note**: Typically you would want to spawn the server in a separate task but that's not what we
> did in the example above. Please refer to [`Server::run` docs] for the reason.

For ready-to-run examples you can execute with `cargo run`, see the [`examples`](zlink/examples)
directory.

## Code Generation from IDL

zlink-codegen can generate Rust code from Varlink interface description files:
Expand Down Expand Up @@ -375,24 +380,6 @@ enum ProcessError {
}
```

## Examples

The repository includes a few examples:

- **[resolved.rs](zlink/examples/resolved.rs)**: DNS resolution using systemd-resolved's Varlink
service
- **[varlink-inspect.rs](zlink/examples/varlink-inspect.rs)**: Service introspection tool

Run examples with:

```bash
cargo run --example resolved -- example.com systemd.io
cargo run \
--example varlink-inspect \
--features idl-parse,introspection -- \
/run/systemd/resolve/io.systemd.Resolve
```

## Features

### Main Features
Expand Down Expand Up @@ -431,6 +418,7 @@ This project is licensed under the [MIT License][license].
[`zlink`]: https://docs.rs/zlink
[`zlink-core`]: https://docs.rs/zlink-core
[`zlink-tokio`]: https://docs.rs/zlink-tokio
[`zlink-smol`]: https://docs.rs/zlink-smol
[`zlink-codegen`]: https://docs.rs/zlink-codegen
[`zlink-macros`]: https://docs.rs/zlink-macros
[`Server::run` docs]: https://docs.rs/zlink/latest/zlink/struct.Server.html#method.run
17 changes: 17 additions & 0 deletions zlink/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

This directory contains examples demonstrating the usage of the zlink library.

## resolved

A CLI tool that resolves hostnames to IP addresses using `systemd-resolved`'s Varlink service.

### Description

The `resolved` example demonstrates how to use the `#[proxy]` macro to generate a type-safe client
API, and how to use request pipelining to send multiple resolution requests at once. It connects to
`systemd-resolved` over its Unix domain socket and prints the resolved addresses for each hostname.

### Usage

```bash
# Resolve one or more hostnames
cargo run --example resolved -- example.com systemd.io
```

## varlink-inspect

A CLI tool for inspecting Varlink services via Unix domain sockets.
Expand Down
Loading