Skip to main content

gix_utils/
lib.rs

1//! A crate with utilities that don't need feature toggles.
2//!
3//! If they would need feature toggles, they should be in `gix-features` instead.
4//!
5//! ## Examples
6//!
7//! ```
8//! use std::time::Duration;
9//!
10//! use gix_utils::{backoff::Quadratic};
11//!
12//! let waits: Vec<_> = Quadratic::default().take(3).collect();
13//! assert_eq!(waits, vec![
14//!     Duration::from_millis(1),
15//!     Duration::from_millis(4),
16//!     Duration::from_millis(9),
17//! ]);
18//! ```
19#![deny(rust_2018_idioms, missing_docs)]
20#![forbid(unsafe_code)]
21
22///
23pub mod backoff;
24
25///
26pub mod buffers;
27
28///
29pub mod str;
30
31///
32pub mod btoi;
33
34/// A utility to do buffer-swapping with.
35///
36/// Use `src` to read from and `dest` to write to, and after actually changing data, call [Buffers::swap()].
37/// To be able to repeat the process, this time using what was `dest` as `src`, freeing up `dest` for writing once more.
38///
39/// Note that after each [`Buffers::swap()`], `src` is the most recent version of the data, just like before each swap.
40#[derive(Default, Clone)]
41pub struct Buffers {
42    /// The source data, as basis for processing.
43    pub src: Vec<u8>,
44    /// The data produced after processing `src`.
45    pub dest: Vec<u8>,
46}