1#![cfg_attr(
8 all(doc, feature = "document-features"),
9 doc = ::document_features::document_features!()
10)]
11#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
12#![deny(missing_docs, rust_2018_idioms)]
13#![forbid(unsafe_code)]
14
15#[cfg(feature = "async-trait")]
16pub use async_trait;
17pub use bstr;
18#[cfg(feature = "futures-io")]
19pub use futures_io;
20pub use gix_packetline as packetline;
21
22#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25pub enum Protocol {
26 V0 = 0,
28 V1 = 1,
30 #[default]
33 V2 = 2,
34}
35
36#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
38#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
39pub enum Service {
40 UploadPack,
42 ReceivePack,
44}
45
46impl Service {
47 pub fn as_str(&self) -> &'static str {
49 match self {
50 Service::ReceivePack => "git-receive-pack",
51 Service::UploadPack => "git-upload-pack",
52 }
53 }
54}
55
56mod traits {
57 use std::convert::Infallible;
58
59 pub trait IsSpuriousError: std::error::Error {
61 fn is_spurious(&self) -> bool {
63 false
64 }
65 }
66
67 impl IsSpuriousError for Infallible {}
68
69 impl IsSpuriousError for std::io::Error {
70 fn is_spurious(&self) -> bool {
71 use std::io::ErrorKind::*;
73 match self.kind() {
74 Unsupported | WriteZero | InvalidInput | InvalidData | WouldBlock | AlreadyExists
75 | AddrNotAvailable | NotConnected | Other | PermissionDenied | NotFound => false,
76 Interrupted | UnexpectedEof | OutOfMemory | TimedOut | BrokenPipe | AddrInUse | ConnectionAborted
77 | ConnectionReset | ConnectionRefused => true,
78 _ => false,
79 }
80 }
81 }
82}
83pub use traits::IsSpuriousError;
84
85pub mod client;