1 //! This is a fairly simple unpacked error representation that's used on
2 //! non-64bit targets, where the packed 64 bit representation wouldn't work, and
3 //! would have no benefit.
5 use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}
;
8 type Inner
= ErrorData
<Box
<Custom
>>;
10 pub(super) struct Repr(Inner
);
14 pub(super) fn new(dat
: ErrorData
<Box
<Custom
>>) -> Self {
17 pub(super) fn new_custom(b
: Box
<Custom
>) -> Self {
18 Self(Inner
::Custom(b
))
21 pub(super) fn new_os(code
: RawOsError
) -> Self {
25 pub(super) fn new_simple(kind
: ErrorKind
) -> Self {
26 Self(Inner
::Simple(kind
))
29 pub(super) const fn new_simple_message(m
: &'
static SimpleMessage
) -> Self {
30 Self(Inner
::SimpleMessage(m
))
33 pub(super) fn into_data(self) -> ErrorData
<Box
<Custom
>> {
37 pub(super) fn data(&self) -> ErrorData
<&Custom
> {
39 Inner
::Os(c
) => ErrorData
::Os(*c
),
40 Inner
::Simple(k
) => ErrorData
::Simple(*k
),
41 Inner
::SimpleMessage(m
) => ErrorData
::SimpleMessage(*m
),
42 Inner
::Custom(m
) => ErrorData
::Custom(&*m
),
46 pub(super) fn data_mut(&mut self) -> ErrorData
<&mut Custom
> {
48 Inner
::Os(c
) => ErrorData
::Os(*c
),
49 Inner
::Simple(k
) => ErrorData
::Simple(*k
),
50 Inner
::SimpleMessage(m
) => ErrorData
::SimpleMessage(*m
),
51 Inner
::Custom(m
) => ErrorData
::Custom(&mut *m
),