You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
pub mod descr;
|
|
pub mod git;
|
|
pub mod mux;
|
|
|
|
pub use descr::Descr;
|
|
|
|
use crate::error::unexpected;
|
|
use crate::util;
|
|
|
|
#[derive(thiserror::Error, Clone, Debug, PartialEq)]
|
|
pub enum SyncError {
|
|
#[error("invalid url")]
|
|
InvalidURL,
|
|
|
|
#[error("unavailable due to server-side issue")]
|
|
Unavailable,
|
|
|
|
#[error("invalid branch name")]
|
|
InvalidBranchName,
|
|
|
|
#[error("already in progress")]
|
|
AlreadyInProgress,
|
|
|
|
#[error(transparent)]
|
|
Unexpected(#[from] unexpected::Error),
|
|
}
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
pub enum GetFileError {
|
|
#[error("descr not synced")]
|
|
DescrNotSynced,
|
|
|
|
#[error("file not found")]
|
|
FileNotFound,
|
|
|
|
#[error("unavailable due to server-side issue")]
|
|
Unavailable,
|
|
|
|
#[error("path is directory")]
|
|
PathIsDirectory,
|
|
|
|
#[error(transparent)]
|
|
Unexpected(#[from] unexpected::Error),
|
|
}
|
|
|
|
/// Describes a storage mechanism for Origins. Each Origin is uniquely identified by its Descr.
|
|
pub trait Store {
|
|
/// If the origin is of a kind which can be updated, sync will pull down the latest version of
|
|
/// the origin into the storage.
|
|
fn sync(&self, descr: &Descr) -> util::BoxFuture<'_, Result<(), SyncError>>;
|
|
|
|
/// Returns the body of the descr's given path, where path must be absolute.
|
|
fn get_file(
|
|
&self,
|
|
descr: &Descr,
|
|
path: &str,
|
|
) -> util::BoxFuture<'_, Result<util::BoxByteStream, GetFileError>>;
|
|
}
|
|
|