1#![forbid(unsafe_code)]
2
3mod error;
46pub mod proto;
47mod push_tree;
48pub mod session;
49pub mod transport;
50pub mod tree;
51
52pub use error::{Error, ErrorCode, Result};
53#[doc(hidden)]
54pub use proto::{Encoding, Expected, RefOutcome, RefState, RefUpdate};
55pub use push_tree::{TreePushOptions, push_tree, push_tree_over_stream, push_tree_prepared};
56#[doc(hidden)]
57pub use session::{
58 BoxFuture, Compression, DetachedMetadata, ObjectData, ObjectReader, ObjectSource, PullBody,
59 PullSession, PushOutcome, PushPhase, PushProgress, PushProgressFn, PushProgressSnapshot,
60 PushSession, PushStats, ServerInfo, SessionOptions, StreamSession, StreamSessionOptions,
61};
62#[doc(hidden)]
63pub use transport::{Endpoint, PreparedSession, SshAddress, SshOptions, without_userinfo};
64
65const _: fn() = || {
67 fn assert_send_sync<T: Send + Sync>() {}
68 assert_send_sync::<Error>();
69 assert_send_sync::<proto::Message>();
70 assert_send_sync::<proto::PullHello>();
71 assert_send_sync::<proto::PullHelloReply>();
72 assert_send_sync::<proto::GetReply>();
73 assert_send_sync::<proto::FrameReader<&[u8]>>();
74 assert_send_sync::<proto::ObjectBody<'static, &[u8]>>();
75 assert_send_sync::<proto::FrameWriter<Vec<u8>>>();
76 assert_send_sync::<PushSession>();
77 assert_send_sync::<PushProgress>();
78 assert_send_sync::<PushStats>();
79 assert_send_sync::<PushOutcome>();
80 assert_send_sync::<ServerInfo>();
81 assert_send_sync::<ObjectData>();
82 assert_send_sync::<DetachedMetadata>();
83 assert_send_sync::<Box<dyn ObjectReader>>();
84 assert_send_sync::<PreparedSession>();
85 assert_send_sync::<tree::TreeModel>();
86 assert_send_sync::<tree::EntryMeta>();
87 assert_send_sync::<tree::EntryKind>();
88 assert_send_sync::<tree::EntryAction>();
89 assert_send_sync::<tree::EntryPath>();
90 assert_send_sync::<StreamSession>();
91 assert_send_sync::<PullSession>();
92 assert_send_sync::<PullBody>();
93 assert_send_sync::<StreamSessionOptions>();
94 assert_send_sync::<Endpoint>();
95 assert_send_sync::<SshAddress>();
96 assert_send_sync::<SshOptions>();
97};
98
99#[allow(dead_code)]
101fn stream_session_futures_are_send(
102 address: &SshAddress,
103 options: &SshOptions,
104 session: &StreamSession,
105 owned: StreamSession,
106 selector: &ostrya_core::RefSelector,
107) {
108 fn assert_send<T: Send>(_: &T) {}
109 assert_send(&StreamSession::connect(
110 address,
111 options,
112 StreamSessionOptions::default(),
113 ));
114 assert_send(&StreamSession::over_stream(
115 futures_lite::io::empty(),
116 futures_lite::io::sink(),
117 StreamSessionOptions::default(),
118 ));
119 assert_send(&session.get("config", 1));
120 assert_send(&session.list_refs(selector, Some(selector), 1));
121 assert_send(&owned.finish());
122}
123
124#[allow(dead_code)]
126fn pull_session_futures_are_send(
127 endpoint: &Endpoint,
128 session: &PullSession,
129 owned: PullSession,
130 selector: &ostrya_core::RefSelector,
131) {
132 fn assert_send<T: Send>(_: &T) {}
133 assert_send(&PullSession::connect(
134 endpoint.clone(),
135 StreamSessionOptions::default(),
136 ));
137 assert_send(&PullSession::over_stream(
138 futures_lite::io::empty(),
139 futures_lite::io::sink(),
140 StreamSessionOptions::default(),
141 ));
142 assert_send(&session.fetch_summary());
143 assert_send(&session.fetch_refs(selector, Some(selector)));
144 assert_send(&owned.finish());
145}
146
147#[allow(dead_code)]
150fn scan_future_is_send(root: &std::path::Path, options: tree::ScanOptions) {
151 fn assert_send<T: Send>(_: &T) {}
152 assert_send(&options);
153 assert_send(&tree::TreeModel::scan(root, options));
154}
155
156#[allow(dead_code)]
158fn session_futures_are_send(
159 session: &PushSession,
160 owned: PushSession,
161 source: &dyn ObjectSource,
162 names: &[ostrya_core::ObjectName],
163 commits: &[ostrya_core::Checksum],
164 updates: &[RefUpdate],
165) {
166 fn assert_send<T: Send>(_: &T) {}
167 assert_send(&session.missing(names));
168 assert_send(&session.send(source, names, commits, Compression::None));
169 assert_send(&owned.commit(updates, false));
170 assert_send(&session::export_stream(
171 futures_lite::io::sink(),
172 source,
173 names,
174 commits,
175 updates,
176 Compression::None,
177 SessionOptions::default(),
178 ));
179}
180
181#[allow(dead_code)]
183fn server_commit_future_is_send(owned: PushSession, server_commit: proto::ServerCommit) {
184 fn assert_send<T: Send>(_: &T) {}
185 assert_send(&owned.server_commit(server_commit));
186}
187
188#[allow(dead_code)]
191fn connect_future_is_send(endpoint: &Endpoint, refs: &[String], prepared: PreparedSession) {
192 fn assert_send<T: Send>(_: &T) {}
193 assert_send(&PushSession::connect(
194 endpoint.clone(),
195 refs,
196 SessionOptions::default(),
197 ));
198 assert_send(&PushSession::prepare(endpoint.clone()));
199 assert_send(&prepared.open(refs, SessionOptions::default()));
200}
201
202#[allow(dead_code)]
205fn push_tree_futures_are_send(
206 endpoint: &Endpoint,
207 root: &std::path::Path,
208 prepared: PreparedSession,
209) {
210 fn assert_send<T: Send>(_: &T) {}
211 assert_send(&TreePushOptions::default());
212 assert_send(&push_tree(
213 endpoint.clone(),
214 root,
215 TreePushOptions::default(),
216 ));
217 assert_send(&push_tree_prepared(
218 prepared,
219 root,
220 TreePushOptions::default(),
221 ));
222 assert_send(&push_tree_over_stream(
223 futures_lite::io::empty(),
224 futures_lite::io::sink(),
225 root,
226 TreePushOptions::default(),
227 ));
228}