This repository has no description
1use knot_types::Oid;
2
3#[derive(Debug, Clone, Default, PartialEq, Eq)]
4pub struct WantOids(Vec<Oid>);
5
6#[derive(Debug, Clone, Default, PartialEq, Eq)]
7pub struct HaveOids(Vec<Oid>);
8
9impl WantOids {
10 pub fn new(oids: Vec<Oid>) -> Self {
11 Self(oids)
12 }
13
14 pub fn as_slice(&self) -> &[Oid] {
15 &self.0
16 }
17
18 pub fn wants(&self) -> knot_git::Wants<'_> {
19 knot_git::Wants::new(&self.0)
20 }
21
22 pub fn iter(&self) -> std::slice::Iter<'_, Oid> {
23 self.0.iter()
24 }
25
26 pub fn len(&self) -> usize {
27 self.0.len()
28 }
29
30 pub fn is_empty(&self) -> bool {
31 self.0.is_empty()
32 }
33}
34
35impl FromIterator<Oid> for WantOids {
36 fn from_iter<I: IntoIterator<Item = Oid>>(iter: I) -> Self {
37 Self(iter.into_iter().collect())
38 }
39}
40
41impl HaveOids {
42 pub fn new(oids: Vec<Oid>) -> Self {
43 Self(oids)
44 }
45
46 pub fn as_slice(&self) -> &[Oid] {
47 &self.0
48 }
49
50 pub fn haves(&self) -> knot_git::Haves<'_> {
51 knot_git::Haves::new(&self.0)
52 }
53
54 pub fn iter(&self) -> std::slice::Iter<'_, Oid> {
55 self.0.iter()
56 }
57
58 pub fn len(&self) -> usize {
59 self.0.len()
60 }
61
62 pub fn is_empty(&self) -> bool {
63 self.0.is_empty()
64 }
65}
66
67impl FromIterator<Oid> for HaveOids {
68 fn from_iter<I: IntoIterator<Item = Oid>>(iter: I) -> Self {
69 Self(iter.into_iter().collect())
70 }
71}