Skip to main content

Crate unifly_core

Crate unifly_core 

Source
Expand description

Reactive data layer between unifly-api and UI consumers (CLI / TUI).

This crate owns the business logic, domain model, and reactive data infrastructure for the UniFi CLI workspace:

  • Controller — Central facade managing the full lifecycle: connect() authenticates, fetches an initial data snapshot, then spawns background tasks for periodic refresh and command processing. Controller::oneshot() provides a lightweight fire-and-forget mode for single CLI invocations.

  • DataStore — Lock-free reactive storage built on EntityCollection<T> (DashMap + tokio::sync::watch channels). Merges Integration and Legacy API responses into canonical domain types.

  • EntityStream<T> — Subscription handle vended by the DataStore. Exposes current() / latest() / changed() for TUI reactive rendering.

  • Command — Typed mutation requests routed through an mpsc channel to the controller’s command processor. Reads bypass the channel via direct DataStore snapshots or ad-hoc API queries.

  • Domain model (model) — Canonical types (Device, Client, Network, FirewallPolicy, Event, etc.) with EntityId supporting both UUID (Integration API) and string-based (Legacy API) identifiers.

Re-exports§

pub use command::Command;
pub use command::CommandResult;
pub use config::AuthCredentials;
pub use config::ControllerConfig;
pub use config::TlsVerification;
pub use controller::ConnectionState;
pub use controller::Controller;
pub use error::CoreError;
pub use store::DataStore;
pub use stream::EntityStream;
pub use model::AclRule;
pub use model::Admin;
pub use model::Alarm;
pub use model::Client;
pub use model::ClientType;
pub use model::Country;
pub use model::Device;
pub use model::DeviceState;
pub use model::DeviceType;
pub use model::DpiApplication;
pub use model::DpiCategory;
pub use model::EntityId;
pub use model::Event;
pub use model::EventCategory;
pub use model::EventSeverity;
pub use model::FirewallPolicy;
pub use model::FirewallZone;
pub use model::HealthSummary;
pub use model::MacAddress;
pub use model::Network;
pub use model::RadiusProfile;
pub use model::Site;
pub use model::SysInfo;
pub use model::SystemInfo;
pub use model::TrafficMatchingList;
pub use model::VpnServer;
pub use model::VpnTunnel;
pub use model::WanInterface;
pub use command::requests::*;

Modules§

command
config
controller
convert
error
model
store
stream