use std::fmt;
use bytes::Bytes;
use crate::{DownloadedReport, ReportId, ReportMetadata, ServiceMessage};
#[derive(Clone, Eq, PartialEq)]
pub struct BinaryReport {
pub metadata: ReportMetadata,
pub messages: Vec<ServiceMessage>,
bytes: Bytes,
}
impl BinaryReport {
pub(crate) fn from_downloaded(report: DownloadedReport) -> Self {
Self {
metadata: report.metadata,
messages: report.messages,
bytes: report.bytes,
}
}
pub fn id(&self) -> &ReportId {
self.metadata.id()
}
pub fn as_bytes(&self) -> &Bytes {
&self.bytes
}
pub fn into_bytes(self) -> Bytes {
self.bytes
}
}
impl fmt::Debug for BinaryReport {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("BinaryReport")
.field("message_count", &self.messages.len())
.field("byte_len", &self.bytes.len())
.finish()
}
}