Skip to main content

gix_protocol/
lib.rs

1//! An abstraction over [fetching][fetch()] a pack from the server.
2//!
3//! Generally, there is the following order of operations.
4//!
5//! * create a `Transport`, either blocking or async
6//! * perform a [`handshake()`]
7//! * execute a [`Command`]
8//!     - [list references](LsRefsCommand)
9//!          - create a mapping between [refspecs and references](fetch::RefMap)
10//!     - [receive a pack](fetch())
11//!
12//! ## Feature Flags
13#![cfg_attr(
14    all(doc, feature = "document-features"),
15    doc = ::document_features::document_features!()
16)]
17#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
18#![deny(missing_docs, unsafe_code)]
19
20#[cfg(feature = "handshake")]
21use gix_error::Result;
22
23/// A function that performs a given credential action, trying to obtain credentials for an operation that needs it.
24///
25/// Useful for both `fetch` and `push`.
26#[cfg(feature = "handshake")]
27pub type AuthenticateFn<'a> =
28    Box<dyn FnMut(gix_credentials::helper::Action) -> Result<Option<gix_credentials::protocol::Outcome>> + 'a>;
29
30/// A selector for V2 commands to invoke on the server for purpose of pre-invocation validation.
31#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
32pub enum Command {
33    /// List references.
34    LsRefs,
35    /// Fetch a pack.
36    Fetch,
37}
38pub mod command;
39
40/// Attribute macros and mode flags for sharing async-shaped implementations between client modes.
41#[cfg(any(feature = "blocking-client", feature = "async-client"))]
42pub mod bisync {
43    #[cfg(all(feature = "async-client", not(feature = "blocking-client")))]
44    pub use gix_macros::{discard as only_sync, keep as bisync, keep as only_async};
45    #[cfg(feature = "blocking-client")]
46    pub use gix_macros::{discard as only_async, keep as only_sync, sync as bisync};
47
48    /// Whether the blocking implementation is selected.
49    pub const SYNC: bool = cfg!(feature = "blocking-client");
50    /// Whether the async implementation is selected.
51    pub const ASYNC: bool = !SYNC;
52}
53#[cfg(feature = "async-client")]
54pub use async_trait;
55#[cfg(feature = "async-client")]
56pub use futures_io;
57#[cfg(feature = "async-client")]
58pub use futures_lite;
59#[cfg(feature = "handshake")]
60pub use gix_credentials as credentials;
61/// A convenience export allowing users of gix-protocol to use the transport layer without their own cargo dependency.
62pub use gix_transport as transport;
63
64///
65pub mod fetch;
66#[cfg(any(feature = "blocking-client", feature = "async-client"))]
67pub use fetch::function::fetch;
68
69mod remote_progress;
70pub use remote_progress::RemoteProgress;
71
72///
73pub mod handshake;
74#[cfg(any(feature = "blocking-client", feature = "async-client"))]
75#[cfg(feature = "handshake")]
76pub use handshake::function::handshake;
77#[cfg(feature = "handshake")]
78pub use handshake::hero::Handshake;
79
80///
81pub mod ls_refs;
82#[cfg(any(feature = "blocking-client", feature = "async-client"))]
83pub use ls_refs::function::LsRefsCommand;
84
85mod util;
86pub use util::*;