thin-fetch 0.1.0

Low-level Git crate to fetch objects with high granularity
Documentation
use std::str::FromStr;

#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
pub enum HashKind {
    #[default]
    Sha1,
    Sha256,
}

impl std::fmt::Display for HashKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            HashKind::Sha1 => write!(f, "sha1"),
            HashKind::Sha256 => write!(f, "sha256"),
        }
    }
}

impl FromStr for HashKind {
    type Err = Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Ok(match s {
            "sha1" => Self::Sha1,
            "sha256" => Self::Sha256,
            other => bail!("unsupported object format: {other}"),
        })
    }
}

impl From<HashKind> for gix_hash::Kind {
    fn from(value: HashKind) -> Self {
        match value {
            HashKind::Sha1 => gix_hash::Kind::Sha1,
            HashKind::Sha256 => gix_hash::Kind::Sha256,
        }
    }
}

mod checkout;
pub mod command;
mod delta;
mod error;
pub mod object;
mod pack_decoder;
mod parcel;
mod reference;
mod repo;
mod sorted_pack;
pub mod utils;

pub use checkout::Checkout;
pub use command::{Command, Execute, Fetch, LsRefs};
pub use error::Error;
pub(crate) use error::{WithError, bail, error};
pub use pack_decoder::PackDecoder;
pub use parcel::{Parcel, ParcelDecoder, ParcelEncoder, ParcelItem};
pub use reference::Reference;
pub use repo::Repo;
pub use sorted_pack::SortedPack;