#![cfg_attr(
all(doc, feature = "document-features"),
doc = ::document_features::document_features!()
)]
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
#![deny(missing_docs, rust_2018_idioms)]
#![forbid(unsafe_code)]
#[cfg(feature = "async-trait")]
pub use async_trait;
pub use bstr;
#[cfg(feature = "futures-io")]
pub use futures_io;
pub use gix_packetline as packetline;
#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Protocol {
V0 = 0,
V1 = 1,
#[default]
V2 = 2,
}
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Service {
UploadPack,
ReceivePack,
}
impl Service {
pub fn as_str(&self) -> &'static str {
match self {
Service::ReceivePack => "git-receive-pack",
Service::UploadPack => "git-upload-pack",
}
}
}
mod traits {
use std::convert::Infallible;
pub trait IsSpuriousError: std::error::Error {
fn is_spurious(&self) -> bool {
false
}
}
impl IsSpuriousError for Infallible {}
impl IsSpuriousError for std::io::Error {
fn is_spurious(&self) -> bool {
use std::io::ErrorKind::*;
match self.kind() {
Unsupported | WriteZero | InvalidInput | InvalidData | WouldBlock | AlreadyExists
| AddrNotAvailable | NotConnected | Other | PermissionDenied | NotFound => false,
Interrupted | UnexpectedEof | OutOfMemory | TimedOut | BrokenPipe | AddrInUse | ConnectionAborted
| ConnectionReset | ConnectionRefused => true,
_ => false,
}
}
}
}
pub use traits::IsSpuriousError;
#[allow(clippy::empty_docs)]
pub mod client;
#[doc(inline)]
#[cfg(any(feature = "blocking-client", all(feature = "async-client", feature = "async-std")))]
pub use client::connect;
#[cfg(all(feature = "async-client", feature = "blocking-client"))]
compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");