Skip to main content

Crate sabi

Crate sabi 

Source
Expand description

This crate provides a small framework for Rust, designed to separate application logic from data access.

In this framework, the logic exclusively takes a data access trait as its argument, and all necessary data access is defined by a single data access trait. Conversely, the concrete implementations of data access methods are provided as default methods of DataAcc derived traits, allowing for flexible grouping, often by data service.

The DataHub bridges these two parts. It attaches all DataAcc derived traits, and then, using the override_macro crate, it overrides the methods of the data access trait used by the logic to point to the implementations found in the DataAcc derived traits. This clever use of this macro compensates for Rust’s lack of native method overriding, allowing the logic to interact with data through an abstract interface.

Furthermore, the DataHub provides transaction control for data operations performed within the logic. You can execute logic functions with transaction control using its DataHub::txn method, or without transaction control using its DataHub::run method.

This framework brings clear separation and robustness to Rust application design.

Macros§

uses
Registers a global data source that can be used throughout the application.

Structs§

AsyncGroup
The structure that allows for the concurrent execution of multiple functions using std::thread and waits for all of them to complete.
AutoShutdown
A utility struct that ensures to close and drop global data sources when it goes out of scope.
DataHub
The struct that acts as a central hub for data input/output operations, integrating multiple Data traits (which are passed to business logic functions as their arguments) with DataAcc traits (which implement default data I/O methods for external services).

Enums§

AsyncGroupError
The enum type representing the reasons for errors that can occur within an AsyncGroup.
DataConnError
An enum type representing the reasons for errors that can occur within DataConn operations.
DataHubError
An enum type representing the reasons for errors that can occur within DataHub operations.
DataSrcError
An enum type representing the reasons for errors that can occur within DataSrc operations.

Traits§

DataAcc
This trait provides a mechanism to retrieve a mutable reference to a DataConn object by name, creating it if necessary.
DataConn
The trait that abstracts a connection per session to an external data service, such as a database, file system, or messaging service.
DataSrc
The trait that abstracts a data source responsible for managing connections to external data services, such as databases, file systems, or messaging services.

Functions§

setup
Executes the setup process for all globally registered data sources.
setup_with_order
Executes the setup process for all globally registered data sources, allowing for a specified order of setup for a subset of data sources.
uses
Registers a global data source dynamically at runtime.