#![allow(dead_code)]
use super::qwp_ws_sfa_segment::SfaMappedPayload;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct QwpReceipt {
pub(crate) fsn: u64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum QwpReceiptStatus {
Unknown { fsn: u64 },
Published { fsn: u64 },
Sent { fsn: u64, wire_seq: u64 },
Completed { fsn: u64 },
Terminal { fsn: u64 },
}
impl QwpReceiptStatus {
pub(crate) fn is_pending(&self) -> bool {
matches!(
self,
QwpReceiptStatus::Published { .. } | QwpReceiptStatus::Sent { .. }
)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct SentFrame {
pub(crate) fsn: u64,
pub(crate) wire_seq: u64,
pub(crate) payload_len: usize,
}
#[derive(Debug)]
pub(crate) struct OutboundFrame {
pub(crate) fsn: u64,
pub(crate) wire_seq: u64,
pub(crate) payload: SfaMappedPayload,
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct OutboundFrameView<'a> {
pub(crate) fsn: u64,
pub(crate) wire_seq: u64,
pub(crate) payload: &'a [u8],
}
impl OutboundFrame {
pub(crate) fn sent_frame(&self) -> SentFrame {
SentFrame {
fsn: self.fsn,
wire_seq: self.wire_seq,
payload_len: self.payload.len(),
}
}
pub(crate) fn with_view<R>(&self, f: impl FnOnce(OutboundFrameView<'_>) -> R) -> R {
self.payload.with_bytes(|payload| {
f(OutboundFrameView {
fsn: self.fsn,
wire_seq: self.wire_seq,
payload,
})
})
}
}
impl OutboundFrameView<'_> {
pub(crate) fn sent_frame(&self) -> SentFrame {
SentFrame {
fsn: self.fsn,
wire_seq: self.wire_seq,
payload_len: self.payload.len(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum QueueError {
InvalidCapacity,
EmptyPayload,
FrameCapacityFull {
max_frames: usize,
},
PayloadExceedsByteCapacity {
payload_len: usize,
max_bytes: usize,
},
ByteCapacityFull {
payload_len: usize,
bytes_used: usize,
max_bytes: usize,
},
StorageSpareNotReady {
segment_size_bytes: u64,
allocated_segment_bytes: u64,
max_total_bytes: u64,
},
StorageSegmentCapFull {
segment_size_bytes: u64,
allocated_segment_bytes: u64,
max_total_bytes: u64,
},
NoUnsentFrame,
ProtocolAckWithoutConnection,
ProtocolAckBeyondSent {
wire_seq: u64,
last_sent_wire_seq: Option<u64>,
},
ProtocolAckedUnsentFrame {
fsn: u64,
},
ProtocolRejectWithoutConnection,
ProtocolRejectBeyondSent {
wire_seq: u64,
last_sent_wire_seq: Option<u64>,
},
ProtocolRejectedUnsentFrame {
fsn: u64,
},
OutboundFrameUnavailable {
fsn: u64,
wire_seq: u64,
},
SequenceOverflow,
}