Skip to main content

gix_protocol/handshake/refs/
mod.rs

1use bstr::BStr;
2
3use super::Ref;
4
5impl Ref {
6    /// Provide shared fields referring to the ref itself, namely `(name, target, [peeled])`.
7    /// In case of peeled refs, the tag object itself is returned as it is what the ref directly refers to, and target of the tag is returned
8    /// as `peeled`.
9    /// If `unborn`, the first object id will be the null oid.
10    pub fn unpack(&self) -> (&BStr, Option<&gix_hash::oid>, Option<&gix_hash::oid>) {
11        match self {
12            Ref::Direct { full_ref_name, object } => (full_ref_name.as_ref(), Some(object), None),
13            Ref::Symbolic {
14                full_ref_name,
15                tag,
16                object,
17                ..
18            } => (
19                full_ref_name.as_ref(),
20                Some(tag.as_deref().unwrap_or(object)),
21                tag.as_deref().map(|_| object.as_ref()),
22            ),
23            Ref::Peeled {
24                full_ref_name,
25                tag: object,
26                object: peeled,
27            } => (full_ref_name.as_ref(), Some(object), Some(peeled)),
28            Ref::Unborn {
29                full_ref_name,
30                target: _,
31            } => (full_ref_name.as_ref(), None, None),
32        }
33    }
34}
35
36#[cfg(any(feature = "blocking-client", feature = "async-client"))]
37pub(crate) mod shared;
38
39#[cfg(feature = "async-client")]
40pub(crate) mod async_io;
41#[cfg(all(feature = "async-client", not(feature = "blocking-client")))]
42pub use async_io::{from_v1_refs_received_as_part_of_handshake_and_capabilities, from_v2_refs};
43
44#[cfg(feature = "blocking-client")]
45pub(crate) mod blocking_io;
46#[cfg(feature = "blocking-client")]
47pub use blocking_io::{from_v1_refs_received_as_part_of_handshake_and_capabilities, from_v2_refs};