1use super::Client;
2use crate::Remote;
3use onestore::{CommitError, Stamp, Transaction};
4use std::{io, sync::Arc};
5
6/// Binds every reconciliation operation to one share-relative file and read limit.
7/// Connection loss retires the client; reconnect before subsequent sync attempts.
8pub struct SmbRemote {
9 client: Arc<Client>,
10 path: String,
11 limit: usize,
12}
13
14impl SmbRemote {
15 /// A client shared between remotes serves each of their files over one connection.
16 pub fn new(client: impl Into<Arc<Client>>, path: impl Into<String>, limit: usize) -> Self {
17 Self {
18 client: client.into(),
19 path: path.into(),
20 limit,
21 }
22 }
23}
24
25impl Remote for SmbRemote {
26 fn read(&mut self) -> io::Result<Vec<u8>> {
27 self.client.read(&self.path, self.limit)
28 }
29
30 fn stamp(&mut self) -> io::Result<Stamp> {
31 self.client.stamp(&self.path)
32 }
33
34 fn publish(&mut self, transaction: &Transaction) -> Result<(), CommitError> {
35 self.client.commit_transaction(&self.path, transaction)
36 }
37
38 fn confirm(&mut self, base: &Stamp) -> Result<(), CommitError> {
39 self.client.confirm(&self.path, base)
40 }
41}