Reorganize the core API (#60)

This commit is contained in:
Dustin J. Mitchell 2024-11-19 18:22:42 -05:00 committed by GitHub
parent 2b1ad12a79
commit 5ad3b8e8bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 638 additions and 1813 deletions

View file

@ -9,6 +9,7 @@ license = "MIT"
[dependencies]
uuid.workspace = true
anyhow.workspace = true
thiserror.workspace = true
log.workspace = true
env_logger.workspace = true
chrono.workspace = true

13
core/src/error.rs Normal file
View file

@ -0,0 +1,13 @@
/// An error from the [`crate::Server`] type.
///
/// This type represents only circumstances outside the realm of the protocol, and not the specific
/// results descriebd in the protocol documentation.
#[derive(Debug, thiserror::Error)]
pub enum ServerError {
/// There is no client with the given ClientId.
#[error("No such client")]
NoSuchClient,
#[error(transparent)]
Other(#[from] anyhow::Error),
}

View file

@ -7,26 +7,17 @@
//! This crate uses an abstract storage backend. Note that this does not implement the
//! HTTP-specific portions of the protocol, nor provide any storage implementations.
//!
//! ## API Methods
//! ## Usage
//!
//! The following API methods are implemented. These methods are documented in more detail in
//! the protocol documentation.
//!
//! * [`add_version`]
//! * [`get_child_version`]
//! * [`add_snapshot`]
//! * [`get_snapshot`]
//!
//! Each API method takes:
//!
//! * [`StorageTxn`] to access storage. Methods which modify storage will commit the transaction before returning.
//! * [`ServerConfig`] providing basic configuration for the server's behavior.
//! * `client_id` and a [`Client`] providing the client metadata.
//! To use, create a new [`Server`] instance and call the relevant protocol API methods. The
//! arguments and return values correspond closely to the protocol documentation.
mod error;
mod inmemory;
mod server;
mod storage;
pub use error::*;
pub use inmemory::*;
pub use server::*;
pub use storage::*;

File diff suppressed because it is too large Load diff