Skip to content

Commit

Permalink
Reorganize the core API (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche authored Nov 19, 2024
1 parent 2b1ad12 commit 5ad3b8e
Show file tree
Hide file tree
Showing 13 changed files with 638 additions and 1,813 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions core/src/error.rs
Original file line number Diff line number Diff line change
@@ -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),
}
19 changes: 5 additions & 14 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Loading

0 comments on commit 5ad3b8e

Please sign in to comment.