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_stream("config"));
161 assert_send(&bucket.get_stream_strict("config"));
162 assert_send(&bucket.exists("config"));
163 assert_send(&bucket.exists_strict("config"));
164 assert_send(&bucket.put("config", Vec::new()));
165 assert_send(&bucket.put_if_absent("config", Vec::new()));
166 assert_send(&bucket.delete("config"));
167 assert_send(&bucket.list("objects/"));
168 assert_send(&bucket.list_delimited("objects/"));
169 assert_send(&bucket.list_uploads());
170 assert_send(&bucket.put_stream("config", &b""[..], 8 << 20));
171 assert_send(&bucket.abort_upload("config", "id"));
172}
173
174#[allow(dead_code)]
176fn stream_session_futures_are_send(
177 address: &SshAddress,
178 options: &SshOptions,
179 session: &StreamSession,
180 owned: StreamSession,
181 selector: &ostrya_core::RefSelector,
182) {
183 fn assert_send<T: Send>(_: &T) {}
184 assert_send(&StreamSession::connect(
185 address,
186 options,
187 StreamSessionOptions::default(),
188 ));
189 assert_send(&StreamSession::over_stream(
190 futures_lite::io::empty(),
191 futures_lite::io::sink(),
192 StreamSessionOptions::default(),
193 ));
194 assert_send(&session.get("config", 1));
195 assert_send(&session.list_refs(selector, Some(selector), 1));
196 assert_send(&owned.finish());
197}
198
199#[allow(dead_code)]
201fn pull_session_futures_are_send(
202 endpoint: &Endpoint,
203 session: &PullSession,
204 owned: PullSession,
205 selector: &ostrya_core::RefSelector,
206) {
207 fn assert_send<T: Send>(_: &T) {}
208 assert_send(&PullSession::connect(
209 endpoint.clone(),
210 StreamSessionOptions::default(),
211 ));
212 assert_send(&PullSession::over_stream(
213 futures_lite::io::empty(),
214 futures_lite::io::sink(),
215 StreamSessionOptions::default(),
216 ));
217 assert_send(&session.fetch_summary());
218 assert_send(&session.fetch_refs(selector, Some(selector)));
219 assert_send(&owned.finish());
220}
221
222#[allow(dead_code)]
225fn scan_future_is_send(root: &std::path::Path, options: tree::ScanOptions) {
226 fn assert_send<T: Send>(_: &T) {}
227 assert_send(&options);
228 assert_send(&tree::TreeModel::scan(root, options));
229}
230
231#[allow(dead_code)]
234fn scan_tree_future_is_send(root: &std::path::Path, opts: TreePushOptions) {
235 fn assert_send<T: Send>(_: &T) {}
236 assert_send(&scan_tree(root, opts));
237}
238
239#[allow(dead_code)]
241fn session_futures_are_send(
242 session: &PushSession,
243 owned: PushSession,
244 source: &dyn ObjectSource,
245 names: &[ostrya_core::ObjectName],
246 commits: &[ostrya_core::Checksum],
247 updates: &[RefUpdate],
248) {
249 fn assert_send<T: Send>(_: &T) {}
250 assert_send(&session.missing(names));
251 assert_send(&session.send(source, names, commits, Compression::None));
252 assert_send(&owned.commit(updates, false));
253 assert_send(&session::export_stream(
254 futures_lite::io::sink(),
255 source,
256 names,
257 commits,
258 updates,
259 Compression::None,
260 SessionOptions::default(),
261 ));
262}
263
264#[allow(dead_code)]
266fn server_commit_future_is_send(owned: PushSession, server_commit: proto::ServerCommit) {
267 fn assert_send<T: Send>(_: &T) {}
268 assert_send(&owned.server_commit(server_commit));
269}
270
271#[allow(dead_code)]
274fn connect_future_is_send(endpoint: &Endpoint, refs: &[String], prepared: PreparedSession) {
275 fn assert_send<T: Send>(_: &T) {}
276 assert_send(&PushSession::connect(
277 endpoint.clone(),
278 refs,
279 SessionOptions::default(),
280 ));
281 assert_send(&PushSession::prepare(endpoint.clone()));
282 assert_send(&prepared.open(refs, SessionOptions::default()));
283}
284
285#[allow(dead_code)]
288fn push_tree_futures_are_send(
289 endpoint: &Endpoint,
290 root: &std::path::Path,
291 prepared: PreparedSession,
292) {
293 fn assert_send<T: Send>(_: &T) {}
294 assert_send(&TreePushOptions::default());
295 assert_send(&push_tree(
296 endpoint.clone(),
297 root,
298 TreePushOptions::default(),
299 ));
300 assert_send(&push_tree_prepared(
301 prepared,
302 root,
303 TreePushOptions::default(),
304 ));
305 assert_send(&push_tree_over_stream(
306 futures_lite::io::empty(),
307 futures_lite::io::sink(),
308 root,
309 TreePushOptions::default(),
310 ));
311}