Module adapters

Source
Expand description

§Adapters — External System Integration

Adapters implement the port traits to connect the domain to external systems.

§Overview

             PORTS                          ADAPTERS
       ┌──────────────┐              ┌─────────────────────┐
       │  ConfigPort  │◄─────────────│  TomlConfigAdapter  │
       └──────────────┘              │  JsonConfigAdapter  │
                                     └─────────────────────┘
       ┌──────────────┐              ┌─────────────────────┐
       │  PersistPort │◄─────────────│  FileSystemAdapter  │
       └──────────────┘              └─────────────────────┘
       ┌──────────────┐              ┌─────────────────────┐
       │  NotifyPort  │◄─────────────│  DbusNotifyAdapter  │
       └──────────────┘              └─────────────────────┘
       ┌──────────────┐              ┌─────────────────────┐
       │   IpcPort    │◄─────────────│  DbusIpcAdapter     │
       └──────────────┘              └─────────────────────┘

§Available Adapters

AdapterPortDescription
TomlConfigAdapterConfigPortLoad config from TOML files
JsonConfigAdapterConfigPortLoad config from JSON files
FileSystemAdapterPersistPortSave themes to filesystem
DbusNotifyAdapterNotifyPortSend notifications via D-Bus
DbusIpcAdapterIpcPortCommunicate with QuickShell via D-Bus

§Feature Flags

Some adapters are behind feature flags:

  • dbus — Enables DbusNotifyAdapter and DbusIpcAdapter
  • watch — Enables file watching capabilities

§Example

ⓘ
use fernctl::adapters::{TomlConfigAdapter, FileSystemAdapter};
use fernctl::ports::inbound::ConfigPort;
use fernctl::ports::outbound::PersistPort;

// Load configuration
let config_adapter = TomlConfigAdapter::new();
let raw = config_adapter.load_from_file("config.toml")?;
let theme = raw.validate()?.into_theme();

// Save as JSON for QuickShell
let persist_adapter = FileSystemAdapter::new();
persist_adapter.save_theme(&theme, "config.json")?;

Structs§

FileSystemAdapter
Adapter for persisting themes to the filesystem.
JsonConfigAdapter
Adapter for loading configuration from JSON files.
TomlConfigAdapter
Adapter for loading configuration from TOML files.

Functions§

toml_to_json 🔒
Converts a TOML value to a JSON value.