cat_dev/fsemul/sdio/
errors.rs

1//! Errors related to SDIO protocols.
2
3use miette::Diagnostic;
4use thiserror::Error;
5
6/// Error serializing/deserializing the SDIO protocol.
7#[derive(Diagnostic, Error, Debug, PartialEq, Eq)]
8pub enum SDIOProtocolError {
9	/// SDIO addresses are out of range.
10	#[error("The SDIO client requested address: {0:02X}, but max address was: {1:02X}")]
11	#[diagnostic(code(cat_dev::net::parse::fsemul::sdio::address_out_of_range))]
12	AddressOutOfRange(u128, u128),
13	/// The first part of a 'printf' message is a channel identifier which is
14	/// like a stream identifier (think differences between STDIN/STDOUT/STDERR).
15	///
16	/// Unfortunately the channel specified was invalid.
17	#[error("Got an invalid channel to read/write from for sdio/printf, (first byte: {0:02x} should be <0xC), (full channel: {1})")]
18	#[diagnostic(code(cat_dev::net::parse::fsemul::sdio::printf::invalid_channel))]
19	PrintfInvalidChannel(u8, u32),
20	/// All SDIO Printf messages must be 512 bytes long, this one was not.
21	#[error("Packet headed for SDIO PRINTF/CONTROL was size {0}, but needs to be 512 bytes")]
22	#[diagnostic(code(cat_dev::net::parse::fsemul::sdio::printf::invalid_sized_packet))]
23	PrintfInvalidSize(usize),
24	/// Unknown command/packet type came over the SDIO protocol.
25	#[error("Got an unexpected sdio/printf packet type: {0}, not sure how to handle.")]
26	#[diagnostic(code(cat_dev::net::parse::fsemul::sdio::printf::unknown_packet_type))]
27	UnknownPrintfPacketType(u8),
28	/// A 'printf' message, has an inner message type, which we didn't recognize.
29	#[error("Got an unexpected message fragment from an sdio printf packet type: {0}, not sure how to handle.")]
30	#[diagnostic(code(cat_dev::net::parse::fsemul::sdio::printf::unknown_message_type))]
31	UnknownPrintfMessageType(u16),
32}