#[cfg(feature = "alloc")]
#[allow(
unused_imports,
reason = "alloc prelude items; subset used per cfg/feature combination"
)]
use alloc::vec::Vec;
use core::fmt;
use crate::core::matter::Matter;
use crate::core::matter::code::MatterCode;
use crate::core::primitives::Cigar;
use crate::core::primitives::Diger;
use crate::core::primitives::Labeler;
use crate::core::primitives::Noncer;
use crate::core::primitives::Number;
use crate::core::primitives::Prefixer;
use crate::core::primitives::Saider;
use crate::core::primitives::Siger;
use crate::core::primitives::Texter;
use crate::core::primitives::Verser;
use bytes::Bytes;
use super::iter::GroupIter;
use super::quadlet_group::QuadletGroup;
use crate::stream::error::ParseError;
use crate::stream::parse::parse_cigar;
use crate::stream::parse::parse_counter;
use crate::stream::parse::parse_counter_v2;
use crate::stream::parse::parse_diger;
use crate::stream::parse::parse_labeler;
use crate::stream::parse::parse_matter;
use crate::stream::parse::parse_noncer;
use crate::stream::parse::parse_number;
use crate::stream::parse::parse_prefixer;
use crate::stream::parse::parse_saider;
use crate::stream::parse::parse_siger;
use crate::stream::parse::parse_texter;
use crate::stream::parse::parse_verser;
use crate::stream::parse::skip_counter;
use crate::stream::parse::skip_indexer;
pub struct ControllerIdxSigs {
raw: Bytes,
count: u32,
}
impl ControllerIdxSigs {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<impl Fn(&[u8]) -> Result<(Siger<'static>, usize), ParseError> + '_> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (siger, rest) = parse_siger(input)?;
Ok((siger, input.len() - rest.len()))
})
}
pub fn into_vec(self) -> Result<Vec<Siger<'static>>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for ControllerIdxSigs {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ControllerIdxSigs")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct WitnessIdxSigs {
raw: Bytes,
count: u32,
}
impl WitnessIdxSigs {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<impl Fn(&[u8]) -> Result<(Siger<'static>, usize), ParseError> + '_> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (siger, rest) = parse_siger(input)?;
Ok((siger, input.len() - rest.len()))
})
}
pub fn into_vec(self) -> Result<Vec<Siger<'static>>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for WitnessIdxSigs {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WitnessIdxSigs")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct NonTransReceiptCouples {
raw: Bytes,
count: u32,
}
impl NonTransReceiptCouples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(&[u8]) -> Result<((Prefixer<'static>, Cigar<'static>), usize), ParseError> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (prefixer, r) = parse_prefixer(input)?;
let (cigar, r2) = parse_cigar(r)?;
Ok(((prefixer, cigar), input.len() - r2.len()))
})
}
pub fn into_vec(self) -> Result<Vec<(Prefixer<'static>, Cigar<'static>)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for NonTransReceiptCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("NonTransReceiptCouples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct TransReceiptQuadruples {
raw: Bytes,
count: u32,
}
impl TransReceiptQuadruples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
Siger<'static>,
),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (prefixer, r) = parse_prefixer(input)?;
let (seqner, r) = parse_matter(r)?;
let (saider, r) = parse_saider(r)?;
let (siger, r) = parse_siger(r)?;
Ok(((prefixer, seqner, saider, siger), input.len() - r.len()))
})
}
#[allow(
clippy::type_complexity,
reason = "element tuple type matches the CESR group structure"
)]
pub fn into_vec(
self,
) -> Result<
Vec<(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
Siger<'static>,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for TransReceiptQuadruples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TransReceiptQuadruples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct FirstSeenReplayCouples {
raw: Bytes,
count: u32,
}
impl FirstSeenReplayCouples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(Matter<'static, MatterCode>, Matter<'static, MatterCode>),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (seqner, r) = parse_matter(input)?;
let (dater, r) = parse_matter(r)?;
Ok(((seqner, dater), input.len() - r.len()))
})
}
#[allow(
clippy::type_complexity,
reason = "element tuple type matches the CESR group structure"
)]
pub fn into_vec(
self,
) -> Result<Vec<(Matter<'static, MatterCode>, Matter<'static, MatterCode>)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for FirstSeenReplayCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("FirstSeenReplayCouples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct TransIdxSigGroups {
raw: Bytes,
count: u32,
v2: bool,
}
impl TransIdxSigGroups {
pub(crate) const fn new(raw: Bytes, count: u32, v2: bool) -> Self {
Self { raw, count, v2 }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
ControllerIdxSigs,
),
usize,
),
ParseError,
> + '_,
> {
let v2 = self.v2;
GroupIter::new(self.raw.clone(), self.count, move |input| {
let mut offset = 0;
let (prefixer, r) = parse_prefixer(input)?;
offset += input.len() - r.len();
let (seqner, r) = parse_matter(r)?;
offset += input[offset..].len() - r.len();
let (saider, r) = parse_saider(r)?;
offset += input[offset..].len() - r.len();
let counter_size = skip_counter(r)?;
let sub_count = if v2 {
let (_, cnt, _) = parse_counter_v2(r)?;
cnt
} else {
let (_, cnt, _) = parse_counter(r)?;
cnt
};
offset += counter_size;
let mut sigs_len = 0;
for _ in 0..sub_count {
sigs_len += skip_indexer(&r[counter_size + sigs_len..])?;
}
let sigs_bytes = Bytes::copy_from_slice(&r[counter_size..counter_size + sigs_len]);
let ctrl_sigs = ControllerIdxSigs::new(sigs_bytes, sub_count);
offset += sigs_len;
Ok(((prefixer, seqner, saider, ctrl_sigs), offset))
})
}
#[allow(
clippy::type_complexity,
reason = "element tuple type matches the CESR group structure"
)]
pub fn into_vec(
self,
) -> Result<
Vec<(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
ControllerIdxSigs,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for TransIdxSigGroups {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TransIdxSigGroups")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct SealSourceCouples {
raw: Bytes,
count: u32,
}
impl SealSourceCouples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(&[u8]) -> Result<((Matter<'static, MatterCode>, Saider<'static>), usize), ParseError>
+ '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (seqner, r) = parse_matter(input)?;
let (saider, r) = parse_saider(r)?;
Ok(((seqner, saider), input.len() - r.len()))
})
}
pub fn into_vec(
self,
) -> Result<Vec<(Matter<'static, MatterCode>, Saider<'static>)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for SealSourceCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SealSourceCouples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct TransLastIdxSigGroups {
raw: Bytes,
count: u32,
v2: bool,
}
impl TransLastIdxSigGroups {
pub(crate) const fn new(raw: Bytes, count: u32, v2: bool) -> Self {
Self { raw, count, v2 }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(&[u8]) -> Result<((Prefixer<'static>, ControllerIdxSigs), usize), ParseError> + '_,
> {
let v2 = self.v2;
GroupIter::new(self.raw.clone(), self.count, move |input| {
let mut offset = 0;
let (prefixer, r) = parse_prefixer(input)?;
offset += input.len() - r.len();
let counter_size = skip_counter(r)?;
let sub_count = if v2 {
let (_, cnt, _) = parse_counter_v2(r)?;
cnt
} else {
let (_, cnt, _) = parse_counter(r)?;
cnt
};
offset += counter_size;
let mut sigs_len = 0;
for _ in 0..sub_count {
sigs_len += skip_indexer(&r[counter_size + sigs_len..])?;
}
let sigs_bytes = Bytes::copy_from_slice(&r[counter_size..counter_size + sigs_len]);
let ctrl_sigs = ControllerIdxSigs::new(sigs_bytes, sub_count);
offset += sigs_len;
Ok(((prefixer, ctrl_sigs), offset))
})
}
pub fn into_vec(self) -> Result<Vec<(Prefixer<'static>, ControllerIdxSigs)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for TransLastIdxSigGroups {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TransLastIdxSigGroups")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct SealSourceTriples {
raw: Bytes,
count: u32,
}
impl SealSourceTriples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (prefixer, r) = parse_prefixer(input)?;
let (seqner, r) = parse_matter(r)?;
let (saider, r) = parse_saider(r)?;
Ok(((prefixer, seqner, saider), input.len() - r.len()))
})
}
pub fn into_vec(
self,
) -> Result<
Vec<(
Prefixer<'static>,
Matter<'static, MatterCode>,
Saider<'static>,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for SealSourceTriples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SealSourceTriples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct PathedMaterialCouples(pub QuadletGroup);
pub struct AttachmentGroup(pub QuadletGroup);
pub struct GenericGroup(pub QuadletGroup);
pub struct BodyWithAttachmentGroup(pub QuadletGroup);
pub struct NonNativeBodyGroup(pub QuadletGroup);
pub struct ESSRPayloadGroup(pub QuadletGroup);
pub struct DatagramSegmentGroup(pub QuadletGroup);
pub struct ESSRWrapperGroup(pub QuadletGroup);
pub struct FixBodyGroup(pub QuadletGroup);
pub struct MapBodyGroup(pub QuadletGroup);
pub struct GenericMapGroup(pub QuadletGroup);
pub struct GenericListGroup(pub QuadletGroup);
pub struct DigestSealSingles {
raw: Bytes,
count: u32,
}
impl DigestSealSingles {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<impl Fn(&[u8]) -> Result<(Diger<'static>, usize), ParseError> + '_> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (diger, rest) = parse_diger(input)?;
Ok((diger, input.len() - rest.len()))
})
}
pub fn into_vec(self) -> Result<Vec<Diger<'static>>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for DigestSealSingles {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DigestSealSingles")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct MerkleRootSealSingles {
raw: Bytes,
count: u32,
}
impl MerkleRootSealSingles {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<impl Fn(&[u8]) -> Result<(Diger<'static>, usize), ParseError> + '_> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (diger, rest) = parse_diger(input)?;
Ok((diger, input.len() - rest.len()))
})
}
pub fn into_vec(self) -> Result<Vec<Diger<'static>>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for MerkleRootSealSingles {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("MerkleRootSealSingles")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct SealSourceLastSingles {
raw: Bytes,
count: u32,
}
impl SealSourceLastSingles {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<impl Fn(&[u8]) -> Result<(Prefixer<'static>, usize), ParseError> + '_> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (prefixer, rest) = parse_prefixer(input)?;
Ok((prefixer, input.len() - rest.len()))
})
}
pub fn into_vec(self) -> Result<Vec<Prefixer<'static>>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for SealSourceLastSingles {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SealSourceLastSingles")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct BackerRegistrarSealCouples {
raw: Bytes,
count: u32,
}
impl BackerRegistrarSealCouples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(&[u8]) -> Result<((Prefixer<'static>, Diger<'static>), usize), ParseError> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (prefixer, r) = parse_prefixer(input)?;
let (diger, r) = parse_diger(r)?;
Ok(((prefixer, diger), input.len() - r.len()))
})
}
pub fn into_vec(self) -> Result<Vec<(Prefixer<'static>, Diger<'static>)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for BackerRegistrarSealCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BackerRegistrarSealCouples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct TypedDigestSealCouples {
raw: Bytes,
count: u32,
}
impl TypedDigestSealCouples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(&[u8]) -> Result<((Verser<'static>, Diger<'static>), usize), ParseError> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (verser, r) = parse_verser(input)?;
let (diger, r) = parse_diger(r)?;
Ok(((verser, diger), input.len() - r.len()))
})
}
pub fn into_vec(self) -> Result<Vec<(Verser<'static>, Diger<'static>)>, ParseError> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for TypedDigestSealCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TypedDigestSealCouples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct BlindedStateQuadruples {
raw: Bytes,
count: u32,
}
impl BlindedStateQuadruples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Diger<'static>,
Noncer<'static>,
Noncer<'static>,
Labeler<'static>,
),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (diger, r) = parse_diger(input)?;
let (noncer1, r) = parse_noncer(r)?;
let (noncer2, r) = parse_noncer(r)?;
let (labeler, r) = parse_labeler(r)?;
Ok(((diger, noncer1, noncer2, labeler), input.len() - r.len()))
})
}
pub fn into_vec(
self,
) -> Result<
Vec<(
Diger<'static>,
Noncer<'static>,
Noncer<'static>,
Labeler<'static>,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for BlindedStateQuadruples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BlindedStateQuadruples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct BoundStateSextuples {
raw: Bytes,
count: u32,
}
impl BoundStateSextuples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Diger<'static>,
Noncer<'static>,
Noncer<'static>,
Labeler<'static>,
Number,
Noncer<'static>,
),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (diger, r) = parse_diger(input)?;
let (noncer1, r) = parse_noncer(r)?;
let (noncer2, r) = parse_noncer(r)?;
let (labeler, r) = parse_labeler(r)?;
let (number, r) = parse_number(r)?;
let (noncer3, r) = parse_noncer(r)?;
Ok((
(diger, noncer1, noncer2, labeler, number, noncer3),
input.len() - r.len(),
))
})
}
#[allow(
clippy::type_complexity,
reason = "element tuple type matches the CESR group structure"
)]
pub fn into_vec(
self,
) -> Result<
Vec<(
Diger<'static>,
Noncer<'static>,
Noncer<'static>,
Labeler<'static>,
Number,
Noncer<'static>,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for BoundStateSextuples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BoundStateSextuples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
pub struct TypedMediaQuadruples {
raw: Bytes,
count: u32,
}
impl TypedMediaQuadruples {
pub(crate) const fn new(raw: Bytes, count: u32) -> Self {
Self { raw, count }
}
#[allow(
clippy::iter_without_into_iter,
clippy::shadow_reuse,
clippy::type_complexity,
reason = "IntoIterator cannot be implemented for closure-based GroupIter; shadow_reuse is idiomatic for chained parsing"
)]
pub fn iter(
&self,
) -> GroupIter<
impl Fn(
&[u8],
) -> Result<
(
(
Diger<'static>,
Noncer<'static>,
Labeler<'static>,
Texter<'static>,
),
usize,
),
ParseError,
> + '_,
> {
GroupIter::new(self.raw.clone(), self.count, |input| {
let (diger, r) = parse_diger(input)?;
let (noncer, r) = parse_noncer(r)?;
let (labeler, r) = parse_labeler(r)?;
let (texter, r) = parse_texter(r)?;
Ok(((diger, noncer, labeler, texter), input.len() - r.len()))
})
}
pub fn into_vec(
self,
) -> Result<
Vec<(
Diger<'static>,
Noncer<'static>,
Labeler<'static>,
Texter<'static>,
)>,
ParseError,
> {
self.iter().collect()
}
pub const fn count(&self) -> u32 {
self.count
}
pub fn raw_bytes(&self) -> &[u8] {
&self.raw
}
}
impl fmt::Debug for TypedMediaQuadruples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TypedMediaQuadruples")
.field("count", &self.count)
.finish_non_exhaustive()
}
}
impl fmt::Debug for PathedMaterialCouples {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("PathedMaterialCouples")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for AttachmentGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("AttachmentGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for GenericGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("GenericGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for BodyWithAttachmentGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("BodyWithAttachmentGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for NonNativeBodyGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("NonNativeBodyGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for ESSRPayloadGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("ESSRPayloadGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for DatagramSegmentGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("DatagramSegmentGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for ESSRWrapperGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("ESSRWrapperGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for FixBodyGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("FixBodyGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for MapBodyGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("MapBodyGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for GenericMapGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("GenericMapGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
impl fmt::Debug for GenericListGroup {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("GenericListGroup")
.field(&format_args!("[{} quadlets]", self.0.quadlet_count()))
.finish()
}
}
#[derive(Debug)]
pub enum CesrGroup {
ControllerIdxSigs(ControllerIdxSigs),
WitnessIdxSigs(WitnessIdxSigs),
NonTransReceiptCouples(NonTransReceiptCouples),
TransReceiptQuadruples(TransReceiptQuadruples),
FirstSeenReplayCouples(FirstSeenReplayCouples),
TransIdxSigGroups(TransIdxSigGroups),
SealSourceCouples(SealSourceCouples),
TransLastIdxSigGroups(TransLastIdxSigGroups),
SealSourceTriples(SealSourceTriples),
PathedMaterialCouples(PathedMaterialCouples),
AttachmentGroup(AttachmentGroup),
GenericGroup(GenericGroup),
BodyWithAttachmentGroup(BodyWithAttachmentGroup),
NonNativeBodyGroup(NonNativeBodyGroup),
ESSRPayloadGroup(ESSRPayloadGroup),
DatagramSegmentGroup(DatagramSegmentGroup),
ESSRWrapperGroup(ESSRWrapperGroup),
FixBodyGroup(FixBodyGroup),
MapBodyGroup(MapBodyGroup),
GenericMapGroup(GenericMapGroup),
GenericListGroup(GenericListGroup),
DigestSealSingles(DigestSealSingles),
MerkleRootSealSingles(MerkleRootSealSingles),
SealSourceLastSingles(SealSourceLastSingles),
BackerRegistrarSealCouples(BackerRegistrarSealCouples),
TypedDigestSealCouples(TypedDigestSealCouples),
BlindedStateQuadruples(BlindedStateQuadruples),
BoundStateSextuples(BoundStateSextuples),
TypedMediaQuadruples(TypedMediaQuadruples),
}