use super::super::{
AckCommitted, AckGap, AckNoOp, AckRegression, ConnectionConversationCapacityExceeded,
MarkerAckCommitted, MarkerAckEnvelope, MarkerMismatch, MarkerNotDelivered, NoBinding,
ParticipantAckEnvelope, ParticipantUnknown, ResponseEnvelope, Retired, ServerDiscriminant,
ServerValue, StaleAuthority,
};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ParticipantAckResponse {
value: ServerValue,
}
impl ParticipantAckResponse {
#[must_use]
pub const fn connection_conversation_capacity_exceeded(
request: ParticipantAckEnvelope,
limit: u64,
) -> Self {
Self {
value: ServerValue::ConnectionConversationCapacityExceeded(
ConnectionConversationCapacityExceeded::SemanticRequest {
request: ResponseEnvelope::ParticipantAck(request),
limit,
},
),
}
}
pub(crate) const fn from_participant_unknown(value: ParticipantUnknown) -> Self {
Self {
value: ServerValue::ParticipantUnknown(value),
}
}
pub(crate) const fn from_no_binding(value: NoBinding) -> Self {
Self {
value: ServerValue::NoBinding(value),
}
}
pub(crate) const fn from_stale_authority(value: StaleAuthority) -> Self {
Self {
value: ServerValue::StaleAuthority(value),
}
}
pub(crate) const fn from_retired(value: Retired) -> Self {
Self {
value: ServerValue::Retired(value),
}
}
#[must_use]
pub const fn ack_committed(value: AckCommitted) -> Self {
Self {
value: ServerValue::AckCommitted(value),
}
}
#[must_use]
pub const fn ack_no_op(request: ParticipantAckEnvelope) -> Self {
Self {
value: ServerValue::AckNoOp(AckNoOp::participant_ack(request)),
}
}
pub(crate) const fn from_ack_no_op(value: AckNoOp) -> Self {
Self {
value: ServerValue::AckNoOp(value),
}
}
#[must_use]
pub const fn ack_gap(value: AckGap) -> Self {
Self {
value: ServerValue::AckGap(value),
}
}
#[must_use]
pub const fn ack_regression(value: AckRegression) -> Self {
Self {
value: ServerValue::AckRegression(value),
}
}
#[must_use]
pub const fn server_value(&self) -> &ServerValue {
&self.value
}
#[must_use]
pub const fn discriminant(&self) -> ServerDiscriminant {
self.value.discriminant()
}
#[must_use]
pub fn into_server_value(self) -> ServerValue {
self.value
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MarkerAckResponse {
value: ServerValue,
}
impl MarkerAckResponse {
#[must_use]
pub const fn connection_conversation_capacity_exceeded(
request: MarkerAckEnvelope,
limit: u64,
) -> Self {
Self {
value: ServerValue::ConnectionConversationCapacityExceeded(
ConnectionConversationCapacityExceeded::SemanticRequest {
request: ResponseEnvelope::MarkerAck(request),
limit,
},
),
}
}
pub(crate) const fn from_participant_unknown(value: ParticipantUnknown) -> Self {
Self {
value: ServerValue::ParticipantUnknown(value),
}
}
pub(crate) const fn from_no_binding(value: NoBinding) -> Self {
Self {
value: ServerValue::NoBinding(value),
}
}
pub(crate) const fn from_stale_authority(value: StaleAuthority) -> Self {
Self {
value: ServerValue::StaleAuthority(value),
}
}
pub(crate) const fn from_retired(value: Retired) -> Self {
Self {
value: ServerValue::Retired(value),
}
}
#[must_use]
pub const fn marker_ack_committed(value: MarkerAckCommitted) -> Self {
Self {
value: ServerValue::MarkerAckCommitted(value),
}
}
pub(crate) const fn from_ack_no_op(value: AckNoOp) -> Self {
Self {
value: ServerValue::AckNoOp(value),
}
}
pub(crate) const fn from_marker_not_delivered(value: MarkerNotDelivered) -> Self {
Self {
value: ServerValue::MarkerNotDelivered(value),
}
}
pub(crate) const fn from_marker_mismatch(value: MarkerMismatch) -> Self {
Self {
value: ServerValue::MarkerMismatch(value),
}
}
#[must_use]
pub const fn server_value(&self) -> &ServerValue {
&self.value
}
#[must_use]
pub const fn discriminant(&self) -> ServerDiscriminant {
self.value.discriminant()
}
#[must_use]
pub fn into_server_value(self) -> ServerValue {
self.value
}
}