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/// A function that performs a given credential action, trying to obtain credentials for an operation that needs it.
21///
22/// Useful for both `fetch` and `push`.
23#[cfg(feature = "handshake")]
24pub type AuthenticateFn<'a> = Box<dyn FnMut(gix_credentials::helper::Action) -> gix_credentials::protocol::Result + 'a>;
25
26/// A selector for V2 commands to invoke on the server for purpose of pre-invocation validation.
27#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
28pub enum Command {
29    /// List references.
30    LsRefs,
31    /// Fetch a pack.
32    Fetch,
33}
34pub mod command;
35
36/// Attribute macros and mode flags for sharing async-shaped implementations between client modes.
37#[cfg(any(feature = "blocking-client", feature = "async-client"))]
38pub mod bisync {
39    #[cfg(all(feature = "async-client", not(feature = "blocking-client")))]
40    pub use gix_macros::{discard as only_sync, keep as bisync, keep as only_async};
41    #[cfg(feature = "blocking-client")]
42    pub use gix_macros::{discard as only_async, keep as only_sync, sync as bisync};
43
44    /// Whether the blocking implementation is selected.
45    pub const SYNC: bool = cfg!(feature = "blocking-client");
46    /// Whether the async implementation is selected.
47    pub const ASYNC: bool = !SYNC;
48}
49#[cfg(feature = "async-client")]
50pub use async_trait;
51#[cfg(feature = "async-client")]
52pub use futures_io;
53#[cfg(feature = "async-client")]
54pub use futures_lite;
55#[cfg(feature = "handshake")]
56pub use gix_credentials as credentials;
57/// A convenience export allowing users of gix-protocol to use the transport layer without their own cargo dependency.
58pub use gix_transport as transport;
59
60///
61pub mod fetch;
62#[cfg(any(feature = "blocking-client", feature = "async-client"))]
63pub use fetch::function::fetch;
64
65mod remote_progress;
66pub use remote_progress::RemoteProgress;
67
68///
69pub mod handshake;
70#[cfg(any(feature = "blocking-client", feature = "async-client"))]
71#[cfg(feature = "handshake")]
72pub use handshake::function::handshake;
73#[cfg(feature = "handshake")]
74pub use handshake::hero::Handshake;
75
76///
77pub mod ls_refs;
78#[cfg(any(feature = "blocking-client", feature = "async-client"))]
79pub use ls_refs::function::LsRefsCommand;
80
81mod util;
82pub use util::*;