added useful converter

This commit is contained in:
Robin Mueller
2025-09-15 12:26:17 +02:00
parent 023380bbd2
commit 1131f8eea5

View File

@@ -1,4 +1,5 @@
//! CFDP Packet Data Unit (PDU) support.
use crate::cfdp::pdu::ack::InvalidAckedDirectiveCodeError;
use crate::cfdp::*;
use crate::crc::CRC_CCITT_FALSE;
use crate::util::{UnsignedByteField, UnsignedByteFieldU8, UnsignedEnum};
@@ -85,6 +86,15 @@ pub enum PduError {
TlvLv(#[from] TlvLvError),
}
impl From<InvalidAckedDirectiveCodeError> for PduError {
fn from(value: InvalidAckedDirectiveCodeError) -> Self {
Self::InvalidDirectiveType {
found: value.0 as u8,
expected: None,
}
}
}
pub trait WritablePduPacket {
fn len_written(&self) -> usize;
fn write_to_bytes(&self, buf: &mut [u8]) -> Result<usize, PduError>;