gix_protocol/handshake/refs/
blocking_io.rs1use crate::fetch::response::ShallowUpdate;
2use crate::handshake::{refs, refs::parse::Error, Ref};
3
4pub fn from_v2_refs(in_refs: &mut dyn gix_transport::client::ReadlineBufRead) -> Result<Vec<Ref>, Error> {
6 let mut out_refs = Vec::new();
7 while let Some(line) = in_refs.readline().transpose()?.transpose()?.and_then(|l| l.as_bstr()) {
8 out_refs.push(refs::shared::parse_v2(line)?);
9 }
10 Ok(out_refs)
11}
12
13pub fn from_v1_refs_received_as_part_of_handshake_and_capabilities<'a>(
22 in_refs: &mut dyn gix_transport::client::ReadlineBufRead,
23 capabilities: impl Iterator<Item = gix_transport::client::capabilities::Capability<'a>>,
24) -> Result<(Vec<Ref>, Vec<ShallowUpdate>), Error> {
25 let mut out_refs = refs::shared::from_capabilities(capabilities)?;
26 let mut out_shallow = Vec::new();
27 let number_of_possible_symbolic_refs_for_lookup = out_refs.len();
28
29 while let Some(line) = in_refs.readline().transpose()?.transpose()?.and_then(|l| l.as_bstr()) {
30 refs::shared::parse_v1(
31 number_of_possible_symbolic_refs_for_lookup,
32 &mut out_refs,
33 &mut out_shallow,
34 line,
35 )?;
36 }
37 Ok((out_refs.into_iter().map(Into::into).collect(), out_shallow))
38}