rxing/oned/rss/expanded/
expanded_row.rs1use std::{fmt::Display, hash::Hash};
18
19use super::ExpandedPair;
20
21#[derive(Clone)]
25pub struct ExpandedRow {
26 pairs: Vec<ExpandedPair>,
27 rowNumber: u32,
28}
29impl ExpandedRow {
30 pub const fn new(pairs: Vec<ExpandedPair>, rowNumber: u32) -> Self {
31 Self { pairs, rowNumber }
32 }
33
34 pub fn getPairs(&self) -> &[ExpandedPair] {
35 &self.pairs
36 }
37
38 #[cfg(all(test, feature = "image"))]
39 pub(crate) fn getPairsMut(&mut self) -> &mut [ExpandedPair] {
40 &mut self.pairs
41 }
42
43 pub fn getRowNumber(&self) -> u32 {
44 self.rowNumber
45 }
46
47 pub fn isEquivalent(&self, otherPairs: &[ExpandedPair]) -> bool {
48 self.pairs == otherPairs
49 }
50}
51
52impl PartialEq for ExpandedRow {
53 fn eq(&self, other: &Self) -> bool {
57 self.pairs == other.pairs
58 }
59}
60
61impl Hash for ExpandedRow {
62 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
63 self.pairs.hash(state);
64 }
65}
66
67impl Display for ExpandedRow {
68 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69 write!(f, "{{ ")?;
70 for p in &self.pairs {
71 write!(f, "{p}")?;
72 }
73 write!(f, " }}") }
75}