1#![recursion_limit = "128"]
6
7use std::result;
8use thiserror::Error;
9
10mod avc;
11mod avctp;
12
13pub use crate::avctp::{
14 Command as AvctpCommand, CommandStream as AvctpCommandStream, MessageType as AvctpMessageType,
15 PacketType as AvctpPacketType, Peer as AvctpPeer,
16};
17
18pub use crate::avc::{
19 Command as AvcCommand, CommandResponse as AvcCommandResponse,
20 CommandStream as AvcCommandStream, CommandType as AvcCommandType, OpCode as AvcOpCode,
21 PacketType as AvcPacketType, Peer as AvcPeer, ResponseType as AvcResponseType,
22};
23
24#[derive(Error, Debug, PartialEq)]
26pub enum Error {
27 #[error("Value was out of range")]
29 OutOfRange,
30
31 #[error("Invalid profile id")]
33 InvalidProfileId,
34
35 #[error("Invalid Header for a AVCTP message")]
37 InvalidHeader,
38
39 #[error("Failed to parse AVCTP message contents")]
41 InvalidMessage,
42
43 #[error("Command timed out")]
45 Timeout,
46
47 #[error("Peer has disconnected")]
49 PeerDisconnected,
50
51 #[error("Command Response has already been received")]
53 AlreadyReceived,
54
55 #[error("Encountered an IO error reading from the peer: {}", _0)]
57 PeerRead(zx::Status),
58
59 #[error("Encountered an IO error writing to the peer: {}", _0)]
61 PeerWrite(zx::Status),
62
63 #[error("Encountered an error encoding a message")]
65 Encoding,
66
67 #[error("Invalid request detected")]
70 RequestInvalid,
71
72 #[error("Command type is not a response")]
74 ResponseTypeInvalid,
75
76 #[error("Response command type is unexpected")]
78 UnexpectedResponse,
79
80 #[doc(hidden)]
81 #[error("__Nonexhaustive error should never be created.")]
82 __Nonexhaustive,
83}
84
85pub(crate) type Result<T> = result::Result<T, Error>;