1#![forbid(unsafe_code)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4mod error;
56pub mod proto;
57mod push_tree;
58#[cfg(feature = "s3")]
59pub mod s3;
60pub mod session;
61pub mod transport;
62pub mod tree;
63
64pub use error::{Error, ErrorCode, Result};
65#[doc(hidden)]
66pub use proto::{Encoding, Expected, RefOutcome, RefState, RefUpdate};
67pub use push_tree::{
68 ScannedTree, TreePushOptions, push_tree, push_tree_over_stream, push_tree_prepared, scan_tree,
69};
70#[doc(hidden)]
71pub use session::{
72 BoxFuture, Compression, DetachedMetadata, ObjectData, ObjectReader, ObjectSource, PullBody,
73 PullSession, PushOutcome, PushPhase, PushProgress, PushProgressFn, PushProgressSnapshot,
74 PushSession, PushStats, ServerInfo, SessionOptions, StreamSession, StreamSessionOptions,
75};
76#[doc(hidden)]
77pub use transport::{Endpoint, PreparedSession, SshAddress, SshOptions, without_userinfo};
78
79const _: fn() = || {
81 fn assert_send_sync<T: Send + Sync>() {}
82 assert_send_sync::<Error>();
83 assert_send_sync::<proto::Message>();
84 assert_send_sync::<proto::PullHello>();
85 assert_send_sync::<proto::PullHelloReply>();
86 assert_send_sync::<proto::GetReply>();
87 assert_send_sync::<proto::FrameReader<&[u8]>>();
88 assert_send_sync::<proto::ObjectBody<'static, &[u8]>>();
89 assert_send_sync::<proto::FrameWriter<Vec<u8>>>();
90 assert_send_sync::<PushSession>();
91 assert_send_sync::<PushProgress>();
92 assert_send_sync::<PushStats>();
93 assert_send_sync::<PushOutcome>();
94 assert_send_sync::<ServerInfo>();
95 assert_send_sync::<ObjectData>();
96 assert_send_sync::<DetachedMetadata>();
97 assert_send_sync::<Box<dyn ObjectReader>>();
98 assert_send_sync::<PreparedSession>();
99 assert_send_sync::<tree::TreeModel>();
100 assert_send_sync::<ScannedTree>();
101 assert_send_sync::<tree::EntryMeta>();
102 assert_send_sync::<tree::EntryKind>();
103 assert_send_sync::<tree::EntryAction>();
104 assert_send_sync::<tree::EntryPath>();
105 assert_send_sync::<StreamSession>();
106 assert_send_sync::<PullSession>();
107 assert_send_sync::<PullBody>();
108 assert_send_sync::<StreamSessionOptions>();
109 assert_send_sync::<Endpoint>();
110 assert_send_sync::<SshAddress>();
111 assert_send_sync::<SshOptions>();
112};
113
114#[cfg(feature = "s3")]
117const _: fn() = || {
118 fn assert_send_sync<T: Send + Sync>() {}
119 assert_send_sync::<s3::SigV4>();
120 assert_send_sync::<s3::Credentials>();
121 assert_send_sync::<s3::Resolved>();
122 assert_send_sync::<s3::Settings>();
123 assert_send_sync::<s3::Environment>();
124 assert_send_sync::<s3::Address>();
125 assert_send_sync::<s3::Location>();
126 assert_send_sync::<s3::S3Endpoint>();
127 assert_send_sync::<s3::Bucket>();
128 assert_send_sync::<s3::Object>();
129 assert_send_sync::<s3::ObjectStream>();
130 assert_send_sync::<s3::PutIfAbsent>();
131 assert_send_sync::<s3::Listing>();
132 assert_send_sync::<s3::Listed>();
133 assert_send_sync::<s3::Upload>();
134};
135
136#[cfg(feature = "s3")]
139#[allow(dead_code)]
140fn s3_resolve_future_is_send(settings: &s3::Settings, environment: &s3::Environment) {
141 fn assert_send<T: Send>(_: &T) {}
142 assert_send(&s3::resolve(settings, environment));
143}
144
145#[cfg(feature = "s3")]
148#[allow(dead_code)]
149fn bucket_futures_are_send(
150 endpoint: &s3::S3Endpoint,
151 bucket: &s3::Bucket,
152 settings: &s3::Settings,
153 environment: &s3::Environment,
154) {
155 fn assert_send<T: Send>(_: &T) {}
156 assert_send(&s3::S3Endpoint::resolve("s3://b/p", settings, environment));
157 assert_send(&s3::Bucket::new(endpoint));
158 assert_send(&bucket.get("config", 1));
159 assert_send(&bucket.get_strict("config", 1));
160 assert_send(&bucket.get_for_pull("config", 1));
161 assert_send(&bucket.get_stream("config"));
162 assert_send(&bucket.get_stream_strict("config"));
163 assert_send(&bucket.exists("config"));
164 assert_send(&bucket.exists_strict("config"));
165 assert_send(&bucket.put("config", Vec::new()));
166 assert_send(&bucket.put_if_absent("config", Vec::new()));
167 assert_send(&bucket.delete("config"));
168 assert_send(&bucket.list("objects/"));
169 assert_send(&bucket.list_delimited("objects/"));
170 assert_send(&bucket.list_uploads());
171 assert_send(&bucket.put_stream("config", &b""[..], 8 << 20));
172 assert_send(&bucket.abort_upload("config", "id"));
173}
174
175#[allow(dead_code)]
177fn stream_session_futures_are_send(
178 address: &SshAddress,
179 options: &SshOptions,
180 session: &StreamSession,
181 owned: StreamSession,
182 selector: &ostrya_core::RefSelector,
183) {
184 fn assert_send<T: Send>(_: &T) {}
185 assert_send(&StreamSession::connect(
186 address,
187 options,
188 StreamSessionOptions::default(),
189 ));
190 assert_send(&StreamSession::over_stream(
191 futures_lite::io::empty(),
192 futures_lite::io::sink(),
193 StreamSessionOptions::default(),
194 ));
195 assert_send(&session.get("config", 1));
196 assert_send(&session.list_refs(selector, Some(selector), 1));
197 assert_send(&owned.finish());
198}
199
200#[allow(dead_code)]
202fn pull_session_futures_are_send(
203 endpoint: &Endpoint,
204 session: &PullSession,
205 owned: PullSession,
206 selector: &ostrya_core::RefSelector,
207) {
208 fn assert_send<T: Send>(_: &T) {}
209 assert_send(&PullSession::connect(
210 endpoint.clone(),
211 StreamSessionOptions::default(),
212 ));
213 assert_send(&PullSession::over_stream(
214 futures_lite::io::empty(),
215 futures_lite::io::sink(),
216 StreamSessionOptions::default(),
217 ));
218 assert_send(&session.fetch_summary());
219 assert_send(&session.fetch_refs(selector, Some(selector)));
220 assert_send(&owned.finish());
221}
222
223#[allow(dead_code)]
226fn scan_future_is_send(root: &std::path::Path, options: tree::ScanOptions) {
227 fn assert_send<T: Send>(_: &T) {}
228 assert_send(&options);
229 assert_send(&tree::TreeModel::scan(root, options));
230}
231
232#[allow(dead_code)]
235fn scan_tree_future_is_send(root: &std::path::Path, opts: TreePushOptions) {
236 fn assert_send<T: Send>(_: &T) {}
237 assert_send(&scan_tree(root, opts));
238}
239
240#[allow(dead_code)]
242fn session_futures_are_send(
243 session: &PushSession,
244 owned: PushSession,
245 source: &dyn ObjectSource,
246 names: &[ostrya_core::ObjectName],
247 commits: &[ostrya_core::Checksum],
248 updates: &[RefUpdate],
249) {
250 fn assert_send<T: Send>(_: &T) {}
251 assert_send(&session.missing(names));
252 assert_send(&session.send(source, names, commits, Compression::None));
253 assert_send(&owned.commit(updates, false));
254 assert_send(&session::export_stream(
255 futures_lite::io::sink(),
256 source,
257 names,
258 commits,
259 updates,
260 Compression::None,
261 SessionOptions::default(),
262 ));
263}
264
265#[allow(dead_code)]
267fn server_commit_future_is_send(owned: PushSession, server_commit: proto::ServerCommit) {
268 fn assert_send<T: Send>(_: &T) {}
269 assert_send(&owned.server_commit(server_commit));
270}
271
272#[allow(dead_code)]
275fn connect_future_is_send(endpoint: &Endpoint, refs: &[String], prepared: PreparedSession) {
276 fn assert_send<T: Send>(_: &T) {}
277 assert_send(&PushSession::connect(
278 endpoint.clone(),
279 refs,
280 SessionOptions::default(),
281 ));
282 assert_send(&PushSession::prepare(endpoint.clone()));
283 assert_send(&prepared.open(refs, SessionOptions::default()));
284}
285
286#[allow(dead_code)]
289fn push_tree_futures_are_send(
290 endpoint: &Endpoint,
291 root: &std::path::Path,
292 prepared: PreparedSession,
293) {
294 fn assert_send<T: Send>(_: &T) {}
295 assert_send(&TreePushOptions::default());
296 assert_send(&push_tree(
297 endpoint.clone(),
298 root,
299 TreePushOptions::default(),
300 ));
301 assert_send(&push_tree_prepared(
302 prepared,
303 root,
304 TreePushOptions::default(),
305 ));
306 assert_send(&push_tree_over_stream(
307 futures_lite::io::empty(),
308 futures_lite::io::sink(),
309 root,
310 TreePushOptions::default(),
311 ));
312}