use crate::common::model::{EntityId, PduBody};
use crate::common::{BodyInfo, Interaction};
use crate::enumerations::{PduType, RepairResponseRepairResult};
use crate::repair_response::builder::RepairResponseBuilder;
use crate::BodyRaw;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
const REPAIR_RESPONSE_BASE_BODY_LENGTH: u16 = 16;
#[derive(Clone, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RepairResponse {
pub receiving_id: EntityId,
pub repairing_id: EntityId,
pub repair_result: RepairResponseRepairResult,
}
impl BodyRaw for RepairResponse {
type Builder = RepairResponseBuilder;
fn builder() -> Self::Builder {
Self::Builder::new()
}
fn into_builder(self) -> Self::Builder {
Self::Builder::new_from_body(self)
}
fn into_pdu_body(self) -> PduBody {
PduBody::RepairResponse(self)
}
}
impl BodyInfo for RepairResponse {
fn body_length(&self) -> u16 {
REPAIR_RESPONSE_BASE_BODY_LENGTH
}
fn body_type(&self) -> PduType {
PduType::RepairResponse
}
}
impl Interaction for RepairResponse {
fn originator(&self) -> Option<&EntityId> {
Some(&self.repairing_id)
}
fn receiver(&self) -> Option<&EntityId> {
Some(&self.receiving_id)
}
}