Skip to main content

Payload

Enum Payload 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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<'_>

Source

pub fn to_owned_payload(&self) -> OwnedPayload

Copy any borrowed payload data into an owned payload.

Source§

impl<'a> Payload<'a>

Source

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<'a> Clone for Payload<'a>

Source§

fn clone(&self) -> Payload<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Payload<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for Payload<'_>

Source§

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

Per-implementation error; constructible from an I/O embedded_io::ErrorKind so the fixed-width write_* leaf helpers lift through ?. Read more
Source§

fn encoded_size(&self) -> Result<usize, MessageError>

Exact number of bytes encode will write. Read more
Source§

fn encode_to_slice( &self, buf: &mut [u8], ) -> Result<usize, EncodeToSliceError<Self::Error>>

Encode into a fixed slice, reporting 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
Source§

impl<'a> Eq for Payload<'a>

Source§

impl<'a> PartialEq for Payload<'a>

Source§

fn eq(&self, other: &Payload<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Payload<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Payload<'a>

§

impl<'a> RefUnwindSafe for Payload<'a>

§

impl<'a> Send for Payload<'a>

§

impl<'a> Sync for Payload<'a>

§

impl<'a> Unpin for Payload<'a>

§

impl<'a> UnsafeUnpin for Payload<'a>

§

impl<'a> UnwindSafe for Payload<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more