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, SimpleMessage};
8 type Inner = ErrorData<Box<Custom>>;
10 pub(super) struct Repr(Inner);
13 pub(super) fn new_custom(b: Box<Custom>) -> Self {
14 Self(Inner::Custom(b))
17 pub(super) fn new_os(code: i32) -> Self {
21 pub(super) fn new_simple(kind: ErrorKind) -> Self {
22 Self(Inner::Simple(kind))
25 pub(super) const fn new_simple_message(m: &'static SimpleMessage) -> Self {
26 Self(Inner::SimpleMessage(m))
29 pub(super) fn into_data(self) -> ErrorData<Box<Custom>> {
33 pub(super) fn data(&self) -> ErrorData<&Custom> {
35 Inner::Os(c) => ErrorData::Os(*c),
36 Inner::Simple(k) => ErrorData::Simple(*k),
37 Inner::SimpleMessage(m) => ErrorData::SimpleMessage(*m),
38 Inner::Custom(m) => ErrorData::Custom(&*m),
42 pub(super) fn data_mut(&mut self) -> ErrorData<&mut Custom> {
44 Inner::Os(c) => ErrorData::Os(*c),
45 Inner::Simple(k) => ErrorData::Simple(*k),
46 Inner::SimpleMessage(m) => ErrorData::SimpleMessage(*m),
47 Inner::Custom(m) => ErrorData::Custom(&mut *m),