Skip to main content

thin_fetch/
lib.rs

1use std::str::FromStr;
2
3#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
4pub enum HashKind {
5    #[default]
6    Sha1,
7    Sha256,
8}
9
10impl std::fmt::Display for HashKind {
11    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12        match self {
13            HashKind::Sha1 => write!(f, "sha1"),
14            HashKind::Sha256 => write!(f, "sha256"),
15        }
16    }
17}
18
19impl FromStr for HashKind {
20    type Err = Error;
21
22    fn from_str(s: &str) -> Result<Self, Self::Err> {
23        Ok(match s {
24            "sha1" => Self::Sha1,
25            "sha256" => Self::Sha256,
26            other => bail!("unsupported object format: {other}"),
27        })
28    }
29}
30
31impl From<HashKind> for gix_hash::Kind {
32    fn from(value: HashKind) -> Self {
33        match value {
34            HashKind::Sha1 => gix_hash::Kind::Sha1,
35            HashKind::Sha256 => gix_hash::Kind::Sha256,
36        }
37    }
38}
39
40mod checkout;
41pub mod command;
42mod delta;
43mod error;
44pub mod object;
45mod pack_decoder;
46mod parcel;
47mod reference;
48mod repo;
49mod sorted_pack;
50pub mod utils;
51
52pub use checkout::Checkout;
53pub use command::{Command, Execute, Fetch, LsRefs};
54pub use error::Error;
55pub(crate) use error::{WithError, bail, error};
56pub use pack_decoder::PackDecoder;
57pub use parcel::{Parcel, ParcelDecoder, ParcelEncoder, ParcelItem};
58pub use reference::Reference;
59pub use repo::Repo;
60pub use sorted_pack::SortedPack;