#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
mod error;
pub mod proto;
mod push_tree;
#[cfg(feature = "s3")]
pub mod s3;
pub mod session;
pub mod transport;
pub mod tree;
pub use error::{Error, ErrorCode, Result};
#[doc(hidden)]
pub use proto::{Encoding, Expected, RefOutcome, RefState, RefUpdate};
pub use push_tree::{
ScannedTree, TreePushOptions, push_tree, push_tree_over_stream, push_tree_prepared, scan_tree,
};
#[doc(hidden)]
pub use session::{
BoxFuture, Compression, DetachedMetadata, ObjectData, ObjectReader, ObjectSource, PullBody,
PullSession, PushOutcome, PushPhase, PushProgress, PushProgressFn, PushProgressSnapshot,
PushSession, PushStats, ServerInfo, SessionOptions, StreamSession, StreamSessionOptions,
};
#[doc(hidden)]
pub use transport::{Endpoint, PreparedSession, SshAddress, SshOptions, without_userinfo};
const _: fn() = || {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<Error>();
assert_send_sync::<proto::Message>();
assert_send_sync::<proto::PullHello>();
assert_send_sync::<proto::PullHelloReply>();
assert_send_sync::<proto::GetReply>();
assert_send_sync::<proto::FrameReader<&[u8]>>();
assert_send_sync::<proto::ObjectBody<'static, &[u8]>>();
assert_send_sync::<proto::FrameWriter<Vec<u8>>>();
assert_send_sync::<PushSession>();
assert_send_sync::<PushProgress>();
assert_send_sync::<PushStats>();
assert_send_sync::<PushOutcome>();
assert_send_sync::<ServerInfo>();
assert_send_sync::<ObjectData>();
assert_send_sync::<DetachedMetadata>();
assert_send_sync::<Box<dyn ObjectReader>>();
assert_send_sync::<PreparedSession>();
assert_send_sync::<tree::TreeModel>();
assert_send_sync::<ScannedTree>();
assert_send_sync::<tree::EntryMeta>();
assert_send_sync::<tree::EntryKind>();
assert_send_sync::<tree::EntryAction>();
assert_send_sync::<tree::EntryPath>();
assert_send_sync::<StreamSession>();
assert_send_sync::<PullSession>();
assert_send_sync::<PullBody>();
assert_send_sync::<StreamSessionOptions>();
assert_send_sync::<Endpoint>();
assert_send_sync::<SshAddress>();
assert_send_sync::<SshOptions>();
};
#[cfg(feature = "s3")]
const _: fn() = || {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<s3::SigV4>();
assert_send_sync::<s3::Credentials>();
assert_send_sync::<s3::Resolved>();
assert_send_sync::<s3::Settings>();
assert_send_sync::<s3::Environment>();
assert_send_sync::<s3::Address>();
assert_send_sync::<s3::Location>();
assert_send_sync::<s3::S3Endpoint>();
assert_send_sync::<s3::Bucket>();
assert_send_sync::<s3::Object>();
assert_send_sync::<s3::ObjectStream>();
assert_send_sync::<s3::PutIfAbsent>();
assert_send_sync::<s3::Listing>();
assert_send_sync::<s3::Listed>();
assert_send_sync::<s3::Upload>();
};
#[cfg(feature = "s3")]
#[allow(dead_code)]
fn s3_resolve_future_is_send(settings: &s3::Settings, environment: &s3::Environment) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&s3::resolve(settings, environment));
}
#[cfg(feature = "s3")]
#[allow(dead_code)]
fn bucket_futures_are_send(
endpoint: &s3::S3Endpoint,
bucket: &s3::Bucket,
settings: &s3::Settings,
environment: &s3::Environment,
) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&s3::S3Endpoint::resolve("s3://b/p", settings, environment));
assert_send(&s3::Bucket::new(endpoint));
assert_send(&bucket.get("config", 1));
assert_send(&bucket.get_strict("config", 1));
assert_send(&bucket.get_for_pull("config", 1));
assert_send(&bucket.get_stream("config"));
assert_send(&bucket.get_stream_strict("config"));
assert_send(&bucket.exists("config"));
assert_send(&bucket.exists_strict("config"));
assert_send(&bucket.put("config", Vec::new()));
assert_send(&bucket.put_if_absent("config", Vec::new()));
assert_send(&bucket.delete("config"));
assert_send(&bucket.list("objects/"));
assert_send(&bucket.list_delimited("objects/"));
assert_send(&bucket.list_uploads());
assert_send(&bucket.put_stream("config", &b""[..], 8 << 20));
assert_send(&bucket.abort_upload("config", "id"));
}
#[allow(dead_code)]
fn stream_session_futures_are_send(
address: &SshAddress,
options: &SshOptions,
session: &StreamSession,
owned: StreamSession,
selector: &ostrya_core::RefSelector,
) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&StreamSession::connect(
address,
options,
StreamSessionOptions::default(),
));
assert_send(&StreamSession::over_stream(
futures_lite::io::empty(),
futures_lite::io::sink(),
StreamSessionOptions::default(),
));
assert_send(&session.get("config", 1));
assert_send(&session.list_refs(selector, Some(selector), 1));
assert_send(&owned.finish());
}
#[allow(dead_code)]
fn pull_session_futures_are_send(
endpoint: &Endpoint,
session: &PullSession,
owned: PullSession,
selector: &ostrya_core::RefSelector,
) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&PullSession::connect(
endpoint.clone(),
StreamSessionOptions::default(),
));
assert_send(&PullSession::over_stream(
futures_lite::io::empty(),
futures_lite::io::sink(),
StreamSessionOptions::default(),
));
assert_send(&session.fetch_summary());
assert_send(&session.fetch_refs(selector, Some(selector)));
assert_send(&owned.finish());
}
#[allow(dead_code)]
fn scan_future_is_send(root: &std::path::Path, options: tree::ScanOptions) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&options);
assert_send(&tree::TreeModel::scan(root, options));
}
#[allow(dead_code)]
fn scan_tree_future_is_send(root: &std::path::Path, opts: TreePushOptions) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&scan_tree(root, opts));
}
#[allow(dead_code)]
fn session_futures_are_send(
session: &PushSession,
owned: PushSession,
source: &dyn ObjectSource,
names: &[ostrya_core::ObjectName],
commits: &[ostrya_core::Checksum],
updates: &[RefUpdate],
) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&session.missing(names));
assert_send(&session.send(source, names, commits, Compression::None));
assert_send(&owned.commit(updates, false));
assert_send(&session::export_stream(
futures_lite::io::sink(),
source,
names,
commits,
updates,
Compression::None,
SessionOptions::default(),
));
}
#[allow(dead_code)]
fn server_commit_future_is_send(owned: PushSession, server_commit: proto::ServerCommit) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&owned.server_commit(server_commit));
}
#[allow(dead_code)]
fn connect_future_is_send(endpoint: &Endpoint, refs: &[String], prepared: PreparedSession) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&PushSession::connect(
endpoint.clone(),
refs,
SessionOptions::default(),
));
assert_send(&PushSession::prepare(endpoint.clone()));
assert_send(&prepared.open(refs, SessionOptions::default()));
}
#[allow(dead_code)]
fn push_tree_futures_are_send(
endpoint: &Endpoint,
root: &std::path::Path,
prepared: PreparedSession,
) {
fn assert_send<T: Send>(_: &T) {}
assert_send(&TreePushOptions::default());
assert_send(&push_tree(
endpoint.clone(),
root,
TreePushOptions::default(),
));
assert_send(&push_tree_prepared(
prepared,
root,
TreePushOptions::default(),
));
assert_send(&push_tree_over_stream(
futures_lite::io::empty(),
futures_lite::io::sink(),
root,
TreePushOptions::default(),
));
}