1 use crate::handshake
::{refs, refs::parse::Error, Ref}
;
3 /// Parse refs from the given input line by line. Protocol V2 is required for this to succeed.
4 pub fn from_v2_refs(in_refs
: &mut dyn gix_transport
::client
::ReadlineBufRead
) -> Result
<Vec
<Ref
>, Error
> {
5 let mut out_refs
= Vec
::new();
6 while let Some(line
) = in_refs
.readline().transpose()?
.transpose()?
.and_then(|l
| l
.as_bstr()) {
7 out_refs
.push(refs
::shared
::parse_v2(line
)?
);
12 /// Parse refs from the return stream of the handshake as well as the server capabilities, also received as part of the
14 /// Together they form a complete set of refs.
18 /// Symbolic refs are shoe-horned into server capabilities whereas refs (without symbolic ones) are sent automatically as
19 /// part of the handshake. Both symbolic and peeled refs need to be combined to fit into the [`Ref`] type provided here.
20 pub fn from_v1_refs_received_as_part_of_handshake_and_capabilities
<'a
>(
21 in_refs
: &mut dyn gix_transport
::client
::ReadlineBufRead
,
22 capabilities
: impl Iterator
<Item
= gix_transport
::client
::capabilities
::Capability
<'a
>>,
23 ) -> Result
<Vec
<Ref
>, Error
> {
24 let mut out_refs
= refs
::shared
::from_capabilities(capabilities
)?
;
25 let number_of_possible_symbolic_refs_for_lookup
= out_refs
.len();
27 while let Some(line
) = in_refs
.readline().transpose()?
.transpose()?
.and_then(|l
| l
.as_bstr()) {
28 refs
::shared
::parse_v1(number_of_possible_symbolic_refs_for_lookup
, &mut out_refs
, line
)?
;
30 Ok(out_refs
.into_iter().map(Into
::into
).collect())