use crate::handshake::{refs, refs::parse::Error, Ref};
pub fn from_v2_refs(in_refs: &mut dyn gix_transport::client::ReadlineBufRead) -> Result<Vec<Ref>, Error> {
let mut out_refs = Vec::new();
while let Some(line) = in_refs.readline().transpose()?.transpose()?.and_then(|l| l.as_bstr()) {
out_refs.push(refs::shared::parse_v2(line)?);
}
Ok(out_refs)
}
pub fn from_v1_refs_received_as_part_of_handshake_and_capabilities<'a>(
in_refs: &mut dyn gix_transport::client::ReadlineBufRead,
capabilities: impl Iterator<Item = gix_transport::client::capabilities::Capability<'a>>,
) -> Result<Vec<Ref>, Error> {
let mut out_refs = refs::shared::from_capabilities(capabilities)?;
let number_of_possible_symbolic_refs_for_lookup = out_refs.len();
while let Some(line) = in_refs.readline().transpose()?.transpose()?.and_then(|l| l.as_bstr()) {
refs::shared::parse_v1(number_of_possible_symbolic_refs_for_lookup, &mut out_refs, line)?;
}
Ok(out_refs.into_iter().map(Into::into).collect())
}