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}
;
7 type Inner
= ErrorData
<Box
<Custom
>>;
9 pub(super) struct Repr(Inner
);
13 pub(super) fn new(dat
: ErrorData
<Box
<Custom
>>) -> Self {
16 pub(super) fn new_custom(b
: Box
<Custom
>) -> Self {
17 Self(Inner
::Custom(b
))
20 pub(super) fn new_os(code
: RawOsError
) -> Self {
24 pub(super) fn new_simple(kind
: ErrorKind
) -> Self {
25 Self(Inner
::Simple(kind
))
28 pub(super) const fn new_simple_message(m
: &'
static SimpleMessage
) -> Self {
29 Self(Inner
::SimpleMessage(m
))
32 pub(super) fn into_data(self) -> ErrorData
<Box
<Custom
>> {
36 pub(super) fn data(&self) -> ErrorData
<&Custom
> {
38 Inner
::Os(c
) => ErrorData
::Os(*c
),
39 Inner
::Simple(k
) => ErrorData
::Simple(*k
),
40 Inner
::SimpleMessage(m
) => ErrorData
::SimpleMessage(*m
),
41 Inner
::Custom(m
) => ErrorData
::Custom(&*m
),
45 pub(super) fn data_mut(&mut self) -> ErrorData
<&mut Custom
> {
47 Inner
::Os(c
) => ErrorData
::Os(*c
),
48 Inner
::Simple(k
) => ErrorData
::Simple(*k
),
49 Inner
::SimpleMessage(m
) => ErrorData
::SimpleMessage(*m
),
50 Inner
::Custom(m
) => ErrorData
::Custom(&mut *m
),