Expand description
This module contains the database implementation for the KMS server.
It provides functionality for interacting with different types of databases,
such as SQLite, MySQL, PostgreSQL, and Redis.
The module includes the following submodules:
cached_sqlcipher: Contains the implementation for caching SQL queries usingSQLCipher.cached_sqlite_struct: Contains the implementation for cachingSQLitestructures.database_trait: Contains the trait definition for a generic database.mysql: Contains the implementation forMySQLdatabase.object_with_metadata: Contains the implementation for objects with metadata.pgsql: Contains the implementation forPostgreSQLdatabase.redis: Contains the implementation for Redis database.sqlite: Contains the implementation forSQLitedatabase.locate_query: Contains utility functions for locating queries.migrate: Contains functions for database migration.retrieve_object_utils: Contains utility functions for retrieving objects.
The module also defines the following types and constants:
KMSServer: A type alias for the KMS server.DBObject: A struct representing a database object.KMS_VERSION_BEFORE_MIGRATION_SUPPORT: A constant representing the KMS version before migration support.PGSQL_FILE_QUERIES: A constant representing thePostgreSQLfile queries.MYSQL_FILE_QUERIES: A constant representing theMySQLfile queries.SQLITE_FILE_QUERIES: A constant representing theSQLitefile queries.
The module also includes the following functions:
state_from_string: Converts a string to aStateEnumerationvalue.
Finally, the module includes a test module for unit testing.
§Errors
This module does not define any specific errors. However, it may return errors from the underlying database operations or from the functions defined in the submodules. The specific error types and conditions are documented in the respective functions.
Modules§
Macros§
- db_bail
- Return early with an error if a condition is not satisfied.
- db_
ensure - Return early with an error if a condition is not satisfied.
- db_
error - Construct a server error from a string.
- get_
mysql_ query
Structs§
- Cached
Unwrapped Object - This is the object kept in the Main LRU cache It contains the unwrapped object and the key signature
- Database
- The
Databasestruct represents the core database functionalities, including object management, permission checks, and caching mechanisms for unwrapped keys. - Unwrapped
Cache - The cache of unwrapped objects
The key is the UID of the object
The value is the unwrapped object
The value is a
Err(KmsError)if the object cannot be unwrapped