fad06fd
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EndpointKind {
GitUploadPack,
GitReceivePack,
LfsBatch,
LfsObjects,
InfoRefs,
SmartHttp,
Custom,
}
impl EndpointKind {
pub fn as_str(&self) -> &'static str {
match self {
Self::GitUploadPack => "git-upload-pack",
Self::GitReceivePack => "git-receive-pack",
Self::LfsBatch => "lfs-batch",
Self::LfsObjects => "lfs-objects",
Self::InfoRefs => "info-refs",
Self::SmartHttp => "smart-http",
Self::Custom => "custom",
}
}
}
#[derive(Debug, Clone)]
pub struct GitProtocolEndpoint {
pub kind: EndpointKind,
pub path: String,
}
impl GitProtocolEndpoint {
pub fn new(kind: EndpointKind, path: impl Into<String>) -> Self {
Self {
kind,
path: path.into(),
}
}
pub fn upload_pack(path: impl Into<String>) -> Self {
Self::new(EndpointKind::GitUploadPack, path)
}
pub fn receive_pack(path: impl Into<String>) -> Self {
Self::new(EndpointKind::GitReceivePack, path)
}
pub fn info_refs(path: impl Into<String>) -> Self {
Self::new(EndpointKind::InfoRefs, path)
}
}