1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use crate::{
BusError, ErrorError, InterfaceError, MemberError, MessageHeaderError, ObjectPathError, Value,
};
use std::num::TryFromIntError;
use std::string::FromUtf8Error;
pub type EncodeResult = Result<(), EncodeError>;
#[derive(Debug, PartialEq)]
pub enum EncodeError {
ArraySignatureMismatch(String, String),
UnknownSignature(String),
NullSignature,
SignatureTooLarge(TryFromIntError),
}
impl From<TryFromIntError> for EncodeError {
fn from(e: TryFromIntError) -> Self {
EncodeError::SignatureTooLarge(e)
}
}
pub type DecodeResult<T> = Result<T, DecodeError>;
#[derive(Debug, PartialEq)]
pub enum DecodeError {
TooShort,
VariantError(Vec<Value>),
InvalidBoolean(u32),
Utf8Error(FromUtf8Error),
StringNotNull,
BusError(BusError),
ObjectPathError(ObjectPathError),
InterfaceError(InterfaceError),
MemberError(MemberError),
ErrorError(ErrorError),
Signature,
SignatureTooBig,
Padding,
ArrayTooBig,
ArrayVecLen,
ArrayLen,
Endianness,
Error,
Header,
MessageType,
MessageFlags,
BodySignatureMissing,
DictVecLen,
ArrayRecursion,
StructRecursion,
OutOfBoundsFds,
BodyLength(usize, usize),
MessageHeaderError(MessageHeaderError),
}
impl From<FromUtf8Error> for DecodeError {
fn from(e: FromUtf8Error) -> Self {
DecodeError::Utf8Error(e)
}
}
impl From<BusError> for DecodeError {
fn from(e: BusError) -> Self {
DecodeError::BusError(e)
}
}
impl From<ObjectPathError> for DecodeError {
fn from(e: ObjectPathError) -> Self {
DecodeError::ObjectPathError(e)
}
}
impl From<InterfaceError> for DecodeError {
fn from(e: InterfaceError) -> Self {
DecodeError::InterfaceError(e)
}
}
impl From<MemberError> for DecodeError {
fn from(e: MemberError) -> Self {
DecodeError::MemberError(e)
}
}
impl From<ErrorError> for DecodeError {
fn from(e: ErrorError) -> Self {
DecodeError::ErrorError(e)
}
}
impl From<MessageHeaderError> for DecodeError {
fn from(e: MessageHeaderError) -> Self {
DecodeError::MessageHeaderError(e)
}
}