use crate::DoIpError;
use std::io::{Read, Write};
pub trait Payload {
fn payload_type() -> PayloadType
where
Self: Sized;
fn length(&self) -> usize;
fn read<T: Read>(reader: &mut T, payload_length: usize) -> Result<Self, DoIpError>
where
Self: Sized;
fn read_replace<T: Read>(
&mut self,
reader: &mut T,
payload_length: usize,
) -> Result<(), DoIpError>
where
Self: Sized;
fn write<T: Write>(&self, writer: &mut T) -> Result<(), DoIpError>
where
Self: Sized;
}
pub trait BorrowedPayload<'a> {
fn read_borrowed(payload: &'a [u8]) -> Result<Self, DoIpError>
where
Self: Sized;
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum PayloadType {
GenericDoIpHeaderNegativeAcknowledge,
VehicleIdentificationRequest,
VehicleIdentificationRequestWithEid,
VehicleIdentificationRequestWithVin,
VehicleIdentificationResponse,
RoutingActivationRequest,
RoutingActivationResponse,
AliveCheckRequest,
AliveCheckResponse,
DoIpEntityStatusRequest,
DoIpEntityStatusResponse,
DiagnosticPowerModeInformationRequest,
DiagnosticPowerModeInformationResponse,
DiagnosticMessage,
DiagnosticMessagePositiveAcknowledgement,
DiagnosticMessageNegativeAcknowledgement,
Reserved(u16),
ReservedVm(u16),
}