1#![cfg_attr(
7 all(doc, feature = "document-features"),
8 doc = ::document_features::document_features!()
9)]
10#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
11#![deny(missing_docs, rust_2018_idioms)]
12#![forbid(unsafe_code)]
13
14#[cfg(feature = "async-trait")]
15pub use async_trait;
16pub use bstr;
17#[cfg(feature = "futures-io")]
18pub use futures_io;
19pub use gix_packetline as packetline;
20
21#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
23#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
24pub enum Protocol {
25 V0 = 0,
27 V1 = 1,
29 #[default]
32 V2 = 2,
33}
34
35#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
37#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
38pub enum Service {
39 UploadPack,
41 ReceivePack,
43}
44
45impl Service {
46 pub fn as_str(&self) -> &'static str {
48 match self {
49 Service::ReceivePack => "git-receive-pack",
50 Service::UploadPack => "git-upload-pack",
51 }
52 }
53}
54
55mod traits {
56 use std::convert::Infallible;
57
58 pub trait IsSpuriousError: std::error::Error {
60 fn is_spurious(&self) -> bool {
62 false
63 }
64 }
65
66 impl IsSpuriousError for Infallible {}
67
68 impl IsSpuriousError for std::io::Error {
69 fn is_spurious(&self) -> bool {
70 use std::io::ErrorKind::*;
72 match self.kind() {
73 Unsupported | WriteZero | InvalidInput | InvalidData | WouldBlock | AlreadyExists
74 | AddrNotAvailable | NotConnected | Other | PermissionDenied | NotFound => false,
75 Interrupted | UnexpectedEof | OutOfMemory | TimedOut | BrokenPipe | AddrInUse | ConnectionAborted
76 | ConnectionReset | ConnectionRefused => true,
77 _ => false,
78 }
79 }
80 }
81}
82pub use traits::IsSpuriousError;
83
84pub mod client;
86
87#[doc(inline)]
88#[cfg(any(feature = "blocking-client", all(feature = "async-client", feature = "async-std")))]
89pub use client::connect;
90
91#[cfg(all(feature = "async-client", feature = "blocking-client"))]
92compile_error!("Cannot set both 'blocking-client' and 'async-client' features as they are mutually exclusive");