#[non_exhaustive]pub enum Payload<'a> {
Show 14 variants
DoIPNack(NackCode),
AliveCheckRequest,
AliveCheckResponse(AliveCheckResponse),
DiagnosticMessage(DiagnosticMessage<'a>),
DiagnosticMessageAck(DiagnosticMessageAck<'a>),
DiagnosticMessageNack,
EntityStatusRequest,
EntityStatusResponse(EntityStatusResponse),
PowerModeInfoResponse(DiagnosticPowerModeCode),
RoutingActivationRequest(RoutingActivationRequest),
RoutingActivationResponse(RoutingActivationResponse),
VehicleAnnouncement(VehicleIdentificationResponse),
VehicleIdentificationRequest,
VehicleIdentificationResponse(VehicleIdentificationResponse),
}Expand description
Maps PayloadType to the corresponding Payload type when reading and writing
messages. This is the main payload type for DoIP messages.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DoIPNack(NackCode)
Generic negative acknowledgement (PayloadType::NegativeAcknowledge, 0x0000):
the header itself was rejected (e.g. bad payload type or length) rather than
the diagnostic content within a valid message.
AliveCheckRequest
Alive check request (PayloadType::AliveCheckRequest, 0x0007), sent by a
DoIP entity to confirm a TCP connection is still active. Carries no data.
AliveCheckResponse(AliveCheckResponse)
Response to an alive check request (PayloadType::AliveCheckResponse, 0x0008),
identifying the responding entity’s logical address.
DiagnosticMessage(DiagnosticMessage<'a>)
A diagnostic message (PayloadType::DiagnosticMessage, 0x8001) carrying a
UDS/diagnostic payload between tester and ECU, addressed by source and
target logical address.
DiagnosticMessageAck(DiagnosticMessageAck<'a>)
Acknowledgement of a diagnostic message. Carries either a positive or a
negative acknowledgement, determined by its
ack_code (see
DiagnosticAckCode::is_negative_ack).
§Known limitation
Message::diagnostic_message_ack
and its owned counterpart currently stamp the positive payload type
(PayloadType::DiagnosticMessagePositiveAcknowledge, 0x8002) into the
header regardless of the ack code, so a negative code is emitted under a
positive payload type. This is a known open issue deferred to a follow-up
change; do not rely on the header’s payload type matching the ack code.
DiagnosticMessageNack
Negative acknowledgement of a diagnostic message
(PayloadType::DiagnosticMessageNegativeAcknowledge, 0x8003): the message
was rejected (e.g. unknown target address, routing not activated).
EntityStatusRequest
Request for the DoIP entity’s status (PayloadType::DoIPEntityStatusRequest,
0x4001): how many diagnostic sockets are open versus the maximum supported.
Carries no data.
EntityStatusResponse(EntityStatusResponse)
Response to an entity status request
(PayloadType::DoIPEntityStatusResponse, 0x4002): node type, open/max
socket counts, and max data size. This implementation always requires and
emits the max data size field, giving a fixed 7-byte payload.
PowerModeInfoResponse(DiagnosticPowerModeCode)
Response to a diagnostic power mode information request
(PayloadType::DiagnosticPowerModeInfoResponse, 0x4004): the vehicle’s
current power mode.
RoutingActivationRequest(RoutingActivationRequest)
Request to activate routing on a TCP connection
(PayloadType::RoutingActivationRequest, 0x0005), sent by the tester before
diagnostic messages may be exchanged.
RoutingActivationResponse(RoutingActivationResponse)
Response to a routing activation request
(PayloadType::RoutingActivationResponse, 0x0006), granting or denying
diagnostic access on the connection.
VehicleAnnouncement(VehicleIdentificationResponse)
Vehicle announcement / vehicle identification response (PayloadType::VehicleAnnouncement,
0x0004). Shares the VehicleIdentificationResponse wire format.
VehicleIdentificationRequest
Request for vehicle identification, in any of its three addressing forms
(PayloadType::VehicleIdentificationRequest 0x0001,
..RequestWithEID 0x0002, or ..RequestWithVIN 0x0003 — this crate does not
distinguish which was received). Broadcast by a tester to discover DoIP
entities on the network. Carries no data.
VehicleIdentificationResponse(VehicleIdentificationResponse)
A directed reply to a specific vehicle identification request, as opposed
to the unsolicited Payload::VehicleAnnouncement. ISO 13400-2 defines a
single wire payload type (0x0004, “vehicle announcement/identification
response message”) for both uses, so this variant encodes identically to
VehicleAnnouncement and Payload::decode never produces it directly —
it exists for callers that want to express “this is a reply to a request”
at construction time.
Implementations§
Source§impl Payload<'_>
impl Payload<'_>
Sourcepub fn to_owned_payload(&self) -> OwnedPayload
pub fn to_owned_payload(&self) -> OwnedPayload
Copy any borrowed payload data into an owned payload.
Source§impl<'a> Payload<'a>
impl<'a> Payload<'a>
Sourcepub fn decode(
buf: &'a [u8],
payload_type: PayloadType,
) -> Result<Self, MessageError>
pub fn decode( buf: &'a [u8], payload_type: PayloadType, ) -> Result<Self, MessageError>
Decode a payload of the given type from exactly the payload bytes of one message.
§Errors
Returns a MessageError if the payload cannot be deserialized
Trait Implementations§
Source§impl Encode for Payload<'_>
impl Encode for Payload<'_>
Source§fn encode(&self, writer: &mut impl Write) -> Result<usize, MessageError>
fn encode(&self, writer: &mut impl Write) -> Result<usize, MessageError>
Serialize this payload into writer
§Errors
Returns a MessageError if the payload cannot be serialized
Source§type Error = MessageError
type Error = MessageError
embedded_io::ErrorKind
so the fixed-width write_* leaf helpers lift through ?. Read moreSource§fn encoded_size(&self) -> Result<usize, MessageError>
fn encoded_size(&self) -> Result<usize, MessageError>
Source§fn encode_to_slice(
&self,
buf: &mut [u8],
) -> Result<usize, EncodeToSliceError<Self::Error>>
fn encode_to_slice( &self, buf: &mut [u8], ) -> Result<usize, EncodeToSliceError<Self::Error>>
needed/available
(InsufficientBuffer) instead of a bare
embedded_io::ErrorKind::WriteZero when the slice is too small, and
hiding the &mut &mut [u8] cursor re-borrow every fixed-buffer call
site otherwise writes by hand. Read more