rsyn/lib.rs
1// Copyright 2020 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![deny(unsafe_code)]
16#![warn(missing_docs)]
17#![warn(future_incompatible)]
18#![warn(rust_2018_idioms)]
19// private_doc_tests is a nice idea but unfortunately warns on types republished
20// by `pub use`.
21// https://github.com/rust-lang/rust/issues/72081
22#![allow(private_doc_tests)]
23// MAYBE: warn(missing-doc-code-examples) but covering everything isn't a
24// priority yet.
25#![warn(intra_doc_link_resolution_failure)]
26
27//! A wire-compatible rsync client in Rust.
28//!
29//! Messages are sent to [`log`](https://docs.rs/log/) and a log destination
30//! may optionally be configured by clients.
31//!
32//! Use the [`Client`](struct.Client.html) type to list or transfer files:
33//!
34//! ```
35//! // Open a connection to a local rsync server, and list the source directory.
36//! use rsyn::{Client, Options};
37//!
38//! let mut client = Client::local("./src");
39//! client.set_recursive(true);
40//! let (flist, _stats) = client.list_files()?;
41//!
42//! // We can see the `lib.rs` in the listing.
43//! assert!(flist.iter().any(|fe|
44//! fe.name_lossy_string().ends_with("lib.rs")));
45//! # rsyn::Result::Ok(())
46//! ```
47
48mod client;
49mod connection;
50mod flist;
51mod mux;
52mod options;
53mod statistics;
54mod varint;
55
56pub use client::Client;
57pub use flist::{FileEntry, FileList};
58pub use options::Options;
59pub use statistics::ServerStatistics;
60
61/// General Result type from rsyn APIs.
62pub type Result<T> = anyhow::Result<T>;