crystal-dbus-native

Version, currently 0.1.14 versions

gitlab.com/renich/crystal-dbus-native

Native, zero-dependency D-Bus wire protocol for Crystal featuring BodyCodec marshaling, SASL EXTERNAL authentication, and SCM_RIGHTS UNIX file descriptor passing.

1 stars
1 dependent
License: GPL-3.0-or-later

Nothing has been indexed for 0.1.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  crystal-dbus-native:
    gitlab: renich/crystal-dbus-native
    version: ~> 0.1.1

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.1. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

GitLab Project Metadata:

  • Description: Native, zero-dependency D-Bus wire protocol for Crystal featuring BodyCodec marshaling, SASL EXTERNAL authentication, and SCM_RIGHTS UNIX file descriptor passing.
  • Topics/Tags: crystal, crystal-lang, dbus, ipc, linux, unix-sockets, scm-rights, zero-dependencies, security, gplv3

Overview

crystal-dbus-native provides a pure, zero-dependency Crystal implementation of the D-Bus wire protocol v1, general-purpose body marshaling (BodyCodec and Variant), SASL EXTERNAL authentication with NEGOTIATE_UNIX_FD negotiation, out-of-band UNIX domain socket file descriptor passing (SCM_RIGHTS), multiplexed fiber RPC routing (ReplyRouter), match-rule signal subscriptions, and typed PropertiesProxy/IntrospectableProxy client helpers.

Key Highlights

  1. Zero C-Library Dependencies: Communicates directly with Linux system and session UNIX domain sockets without libdbus-1 or libsystemd FFI bindings.
  2. Complete Body Marshaling (BodyCodec & Variant): Encodes and decodes all basic D-Bus types, nested structs (StructValue), dictionaries (a{sv}), Variant, ObjectPath, Signature, and UnixFD in both little-endian and big-endian formats with 1, 2, 4, and 8-byte alignment enforcement.
  3. Secure SCM_RIGHTS File Descriptor Passing: Wraps sendmsg/recvmsg with MSG_CMSG_CLOEXEC and guarantees automatic descriptor cleanup on MSG_CTRUNC truncation or framing errors.
  4. Multiplexed Fiber RPC & Signal Subscriptions: ReplyRouter demultiplexes out-of-order replies across concurrent fibers without head-of-line blocking and dispatches AddMatch signal subscriptions to bounded Channel(DBusMessage).new(64) channels.
  5. Standard Interface Client Proxies: PropertiesProxy (get, set, get_all, decode_properties_changed) and IntrospectableProxy (introspect) provide strongly-typed access to standard freedesktop interfaces.

Installation

Add crystal-dbus-native to your application's shard.yml:

dependencies:
  crystal-dbus-native:
    gitlab: renich/crystal-dbus-native
    version: ~> 0.3.1

Then install the shard:

shards install

Usage

require "crystal-dbus-native"

# Connect to the session or system bus and perform SASL + Hello handshake
connection = Crystal::Dbus::Native::DBusConnection.open_session
unique_name = connection.start(negotiate_unix_fd: true)
puts "Connected to D-Bus (unique name: #{unique_name}, GUID: #{connection.server_guid})"

# Invoke a D-Bus method and decode its reply body
reply = connection.call(
  destination: "org.freedesktop.DBus",
  path: "/org/freedesktop/DBus",
  interface: "org.freedesktop.DBus",
  member: "GetId"
)
puts "Bus ID: #{reply.decode_body.first}"

# Inspect XML interfaces or read properties via typed client proxies
introspect = Crystal::Dbus::Native::IntrospectableProxy.new(
  connection,
  "org.freedesktop.DBus",
  "/org/freedesktop/DBus"
)
puts introspect.introspect

props = Crystal::Dbus::Native::PropertiesProxy.new(
  connection,
  "org.freedesktop.DBus",
  "/org/freedesktop/DBus"
)
features = props.get("org.freedesktop.DBus", "Features")
puts "Bus features signature: #{features.signature}"

# Subscribe to D-Bus signals via AddMatch
rule = "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
sig_ch = connection.subscribe_signal(rule)
connection.unsubscribe_signal(rule, sig_ch)

connection.close

Build System Targets

The repository includes a comprehensive, standard GNUmakefile:

TargetDescription
make allRuns lint, doc-check, and test
make testExecutes the spec test suite (crystal spec)
make lintRuns crystal tool format --check, Ameba (--all), and Flaw SAST scanner
make doc-checkLints all reStructuredText files using crstlint and rstcheck
make checkAlias for all (lint, doc-check, and test)
make formatFormats all Crystal source and spec files
make docsGenerates Crystal API docs and Sphinx dirhtml documentation
make depsInstalls Shards dependencies and builds bin/ameba and bin/flaw
make cleanRemoves build artifacts, generated docs, and caches

Documentation

Full architectural blueprints, functional specifications, and operational playbooks are maintained under docs/:

GuideScope & HighlightsEntry Point
Business Context & StrategyEcosystem problem statement, ROI metrics, and user personas.Business Specs
Functional SpecificationsRequirements [FUNC-001]–[FUNC-007] and traceability matrix.Functional Specs
Technical ArchitectureSpecifications [TECH-001]–[TECH-007], D2 diagrams, and threat model.Technical Specs
Release PlaybookSemVer, Keep a Changelog, and GPG-signed GitLab release steps.Release Procedure
Architecture Decisions (ADRs)Immutable logs of architectural decisions and trade-offs.ADR Index
Project RoadmapPhased milestone tracking, task dependencies, and critical paths.Project Roadmap
User GuidesInstallation, RPC usage, and error handling examples.User Manual
Crystal API ReferenceComplete interactive type hierarchy and method signatures.API Reference

Contributing & Code of Honor

All contributions must adhere to the Universal Code of Honor and Contributing Guidelines.


License

  • Software: GNU General Public License v3.0 or later (LICENSE).
  • Documentation: GNU Free Documentation License v1.3 or later (LICENSE-DOCS).

Copyleft © 2026 Rénich Bon Ćirić <renich@evalinux.com>.


Support & Donations

If you find this shard useful and wish to support its ongoing development, please consider donating: