| 1 | // SPDX-License-Identifier: Apache-2.0 or MIT |
| 2 | // |
| 3 | // Copyright 2021 Sony Group Corporation |
| 4 | // |
| 5 | |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 9 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#; |
| 10 | |
| 11 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) type Resultrust-analyzer cargo libseccomp 0.4.0 error/Result#<T> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#>; |
| 12 | |
| 13 | /// Errnos returned by the libseccomp API. |
| 14 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 15 | #[non_exhaustive] |
| 16 | // https://github.com/seccomp/libseccomp/blob/3c0dedd45713d7928c459b6523b78f4cfd435269/src/api.c#L60 |
| 17 | pub enum SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno# { |
| 18 | /// The library doesn't permit the particular operation. |
| 19 | EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#, |
| 20 | /// There was a system failure beyond the control of libseccomp. |
| 21 | ECANCELEDrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ECANCELED#, |
| 22 | /// Architecture/ABI specific failure. |
| 23 | EDOMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EDOM#, |
| 24 | /// Failure regarding the existence of argument. |
| 25 | EEXISTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EEXIST#, |
| 26 | /// Internal libseccomp failure. |
| 27 | EFAULTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EFAULT#, |
| 28 | /// Invalid input to the libseccomp API. |
| 29 | EINVALrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EINVAL#, |
| 30 | /// No matching entry found. |
| 31 | ENOENTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOENT#, |
| 32 | /// Unable to allocate enough memory to perform the requested operation. |
| 33 | ENOMEMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOMEM#, |
| 34 | /// The library doesn't support the particular operation. |
| 35 | EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP#, |
| 36 | /// Provided buffer is too small. |
| 37 | ERANGErust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ERANGE#, |
| 38 | /// Unable to load the filter due to thread issues. |
| 39 | ESRCHrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ESRCH#, |
| 40 | } |
| 41 | |
| 42 | impl SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno# { |
| 43 | fn strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().(&self) -> &'static str { |
| 44 | use SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::*; |
| 45 | |
| 46 | match self { |
| 47 | EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES# => "The library doesn't permit the particular operation", |
| 48 | ECANCELEDrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ECANCELED# => "There was a system failure beyond the control of libseccomp", |
| 49 | EDOMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EDOM# => "Architecture/ABI specific failure", |
| 50 | EEXISTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EEXIST# => "Failure regarding the existence of argument", |
| 51 | EFAULTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EFAULT# => "Internal libseccomp failure", |
| 52 | EINVALrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EINVAL# => "Invalid input to the libseccomp API", |
| 53 | ENOENTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOENT# => "No matching entry found", |
| 54 | ENOMEMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOMEM# => "Unable to allocate enough memory to perform the requested operation", |
| 55 | EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP# => "The library doesn't support the particular operation", |
| 56 | ERANGErust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ERANGE# => "Provided buffer is too small", |
| 57 | ESRCHrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ESRCH# => "Unable to load the filter due to thread issues", |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | fn to_sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]to_sysrawrc().(self) -> i32 { |
| 62 | use SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::*; |
| 63 | |
| 64 | match self { |
| 65 | EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES# => libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES., |
| 66 | ECANCELEDrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ECANCELED# => libcrust-analyzer cargo libc 0.2.189 crate/::ECANCELEDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/ECANCELED., |
| 67 | EDOMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EDOM# => libcrust-analyzer cargo libc 0.2.189 crate/::EDOMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EDOM., |
| 68 | EEXISTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EEXIST# => libcrust-analyzer cargo libc 0.2.189 crate/::EEXISTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EEXIST., |
| 69 | EFAULTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EFAULT# => libcrust-analyzer cargo libc 0.2.189 crate/::EFAULTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EFAULT., |
| 70 | EINVALrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EINVAL# => libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL., |
| 71 | ENOENTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOENT# => libcrust-analyzer cargo libc 0.2.189 crate/::ENOENTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOENT., |
| 72 | ENOMEMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOMEM# => libcrust-analyzer cargo libc 0.2.189 crate/::ENOMEMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOMEM., |
| 73 | EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP# => libcrust-analyzer cargo libc 0.2.189 crate/::EOPNOTSUPPrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EOPNOTSUPP., |
| 74 | ERANGErust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ERANGE# => libcrust-analyzer cargo libc 0.2.189 crate/::ERANGErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ERANGE., |
| 75 | ESRCHrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ESRCH# => libcrust-analyzer cargo libc 0.2.189 crate/::ESRCHrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ESRCH., |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno# { |
| 81 | fn fmtrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 82 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().()) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /// A list specifying different categories of error. |
| 87 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 88 | #[non_exhaustive] |
| 89 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) enum ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind# { |
| 90 | /// An error that represents error code on failure of the libseccomp API. |
| 91 | Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#), |
| 92 | /// A system's raw error code. |
| 93 | SysRawRcrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#SysRawRc#(i32), |
| 94 | /// An invalid Architecture. |
| 95 | InvalidArchrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidArch#(u32), |
| 96 | /// An invalid Action. |
| 97 | InvalidActionrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidAction#(u32), |
| 98 | /// An invalid string in from_str. |
| 99 | FromStrrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#FromStr#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 100 | /// A lower-level error that is caused by an error from a lower-level module. |
| 101 | Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source#, |
| 102 | /// A custom error that does not fall under any other error kind. |
| 103 | Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>), |
| 104 | } |
| 105 | |
| 106 | /// The error type for libseccomp operations. |
| 107 | pub struct SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError# { |
| 108 | kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind.: ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#, |
| 109 | sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>, |
| 110 | } |
| 111 | |
| 112 | impl SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError# { |
| 113 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(kind: ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#) -> Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { |
| 114 | Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind., sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# } |
| 115 | } |
| 116 | |
| 117 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().<E>(kind: ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#, source: E) -> Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] |
| 118 | where |
| 119 | E: Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static, |
| 120 | { |
| 121 | Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { |
| 122 | kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind., |
| 123 | sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(source)), |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn with_msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg().<M>(msg: M) -> Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] |
| 128 | where |
| 129 | M: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>>, |
| 130 | { |
| 131 | Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { |
| 132 | kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind.: ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(msg.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()), |
| 133 | sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | #[allow(dead_code)] |
| 138 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn with_msg_and_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg_and_source().<M, E>(msg: M, source: E) -> Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] |
| 139 | where |
| 140 | M: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str>>, |
| 141 | E: Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# + 'static, |
| 142 | { |
| 143 | Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { |
| 144 | kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind.: ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(msg.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()), |
| 145 | sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(source)), |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(raw_errno: i32) -> Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError] { |
| 150 | let seccomp_errno = match -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().raw_errno { |
| 151 | libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#, |
| 152 | libcrust-analyzer cargo libc 0.2.189 crate/::ECANCELEDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/ECANCELED. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ECANCELEDrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ECANCELED#, |
| 153 | libcrust-analyzer cargo libc 0.2.189 crate/::EDOMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EDOM. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EDOMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EDOM#, |
| 154 | libcrust-analyzer cargo libc 0.2.189 crate/::EEXISTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EEXIST. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EEXISTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EEXIST#, |
| 155 | libcrust-analyzer cargo libc 0.2.189 crate/::EFAULTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EFAULT. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EFAULTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EFAULT#, |
| 156 | libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EINVALrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EINVAL#, |
| 157 | libcrust-analyzer cargo libc 0.2.189 crate/::ENOENTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOENT. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ENOENTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOENT#, |
| 158 | libcrust-analyzer cargo libc 0.2.189 crate/::ENOMEMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOMEM. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ENOMEMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOMEM#, |
| 159 | libcrust-analyzer cargo libc 0.2.189 crate/::EOPNOTSUPPrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EOPNOTSUPP. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP#, |
| 160 | libcrust-analyzer cargo libc 0.2.189 crate/::ERANGErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ERANGE. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ERANGErust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ERANGE#, |
| 161 | libcrust-analyzer cargo libc 0.2.189 crate/::ESRCHrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ESRCH. => SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ESRCHrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ESRCH#, |
| 162 | _ => return Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::SysRawRcrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#SysRawRc#(raw_errno)), |
| 163 | }; |
| 164 | Selfrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(seccomp_errno)) |
| 165 | } |
| 166 | |
| 167 | /// Query the errno returned by the libseccomp API. |
| 168 | pub fn errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]errno().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#> { |
| 169 | if let ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(errno) = self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind. { |
| 170 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(errno) |
| 171 | } else { |
| 172 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /// Query the system's raw error code returned when something goes wrong |
| 177 | /// in the libc and the kernel. |
| 178 | /// |
| 179 | /// This function will be useful for users who want to extract the system's |
| 180 | /// error code directly returned by [`ScmpFilterAttr::ApiSysRawRc`](`crate::ScmpFilterAttr::ApiSysRawRc`) |
| 181 | /// , or get the errno returned by the libseccomp API as a negative integer rather than [`SeccompErrno`]. |
| 182 | /// |
| 183 | /// # Examples |
| 184 | /// |
| 185 | /// ``` |
| 186 | /// # use libseccomp::*; |
| 187 | /// match set_api(1000) { |
| 188 | /// Err(e) => { |
| 189 | /// eprintln!("Error: {e}"); |
| 190 | /// if let Some(sys) = e.sysrawrc() { |
| 191 | /// eprintln!("The system's raw error code: {sys}"); |
| 192 | /// assert_eq!(sys, -libc::EINVAL); |
| 193 | /// } |
| 194 | /// } |
| 195 | /// _ => println!("No error"), |
| 196 | /// } |
| 197 | /// # Ok::<(), Box<dyn std::error::Error>>(()) |
| 198 | /// ``` |
| 199 | pub fn sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]sysrawrc().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<i32> { |
| 200 | match self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind. { |
| 201 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::SysRawRcrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#SysRawRc#(rc) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rc), |
| 202 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(errno) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().errno.to_sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]to_sysrawrc().()), |
| 203 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | /// Returns the raw ffi value of an unsupported Action/Arch. |
| 208 | /// |
| 209 | /// # Examples |
| 210 | /// |
| 211 | /// ``` |
| 212 | /// # use libseccomp::*; |
| 213 | /// let mut ctx = ScmpFilterContext::new(ScmpAction::Allow)?; |
| 214 | /// if let Err(err) = ctx.get_act_default() { |
| 215 | /// println!("{:#?}", err.raw_ffi_value()) |
| 216 | /// } |
| 217 | /// # Ok::<(), Box<dyn std::error::Error>>(()) |
| 218 | /// ``` |
| 219 | pub fn raw_ffi_valuerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]raw_ffi_value().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u32> { |
| 220 | match self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind. { |
| 221 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::InvalidArchrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidArch#(v) | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::InvalidActionrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidAction#(v) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v), |
| 222 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | fn msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str> { |
| 227 | match &self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind. { |
| 228 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(e) => e.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 229 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::SysRawRcrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#SysRawRc#(e) => { |
| 230 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("The system's raw error code({}) was returned", e).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 231 | } |
| 232 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::InvalidArchrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidArch#(_) => "Parse error by invalid architecture".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 233 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::InvalidActionrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidAction#(_) => "Parse error by invalid action".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 234 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::FromStrrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#FromStr#(s) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Error while parsing '{s}'").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 235 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source# => self.sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 236 | ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(s) => s.derefrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`][Deref]deref().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError# { |
| 242 | fn fmtrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 243 | let msg = self.msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(); |
| 244 | |
| 245 | match &self.sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source. { |
| 246 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(source) if self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source# => { |
| 247 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{} caused by: {}", msg, source) |
| 248 | } |
| 249 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 250 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", msg) |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError# { |
| 257 | fn fmtrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 258 | f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Error") |
| 259 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("kind", &self.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind.) |
| 260 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("source", &self.sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source.) |
| 261 | .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("message", &self.msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().()) |
| 262 | .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError# { |
| 267 | fn sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&(dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)> { |
| 268 | match &self.sourcerust-analyzer cargo libseccomp 0.4.0 error/SeccompError#source. { |
| 269 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().()), |
| 270 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* Does not work without specialization (RFC 1210) or negative trait bounds |
| 276 | impl<T: Error> From<T> for SeccompError { |
| 277 | fn from(err: T) -> Self { |
| 278 | Self::with_source(ErrorKind::Source, err) |
| 279 | } |
| 280 | } |
| 281 | */ |
| 282 | |
| 283 | macro_rules! impl_seccomperror_fromrust-analyzer cargo libseccomp 0.4.0 error/impl_seccomperror_from! { |
| 284 | ($errty:ty) => { |
| 285 | impl From<$errty> for SeccompError { |
| 286 | fn from(err: $errty) -> Self { |
| 287 | Self::with_source(ErrorKind::Source, err) |
| 288 | } |
| 289 | } |
| 290 | }; |
| 291 | } |
| 292 | impl_seccomperror_fromrust-analyzer cargo libseccomp 0.4.0 error/impl_seccomperror_from!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::NulErrorrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/NulError#); |
| 293 | impl_seccomperror_fromrust-analyzer cargo libseccomp 0.4.0 error/impl_seccomperror_from!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::TryFromIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/TryFromIntError#); |
| 294 | impl_seccomperror_fromrust-analyzer cargo libseccomp 0.4.0 error/impl_seccomperror_from!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::Utf8Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/error/Utf8Error#); |
| 295 | |
| 296 | #[cfg(test)] |
| 297 | mod testsrust-analyzer cargo libseccomp 0.4.0 error/tests/ { |
| 298 | use superrust-analyzer cargo libseccomp 0.4.0 error/::ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::*; |
| 299 | use superrust-analyzer cargo libseccomp 0.4.0 error/::*; |
| 300 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#; |
| 301 | |
| 302 | const TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG.: &str = "test error"; |
| 303 | const TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.: &str = "f\0oo"; |
| 304 | const NULL_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/NULL_ERR_MSG.: &str = "nul byte found in provided data at position: 1"; |
| 305 | |
| 306 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 307 | fn test_msgrust-analyzer cargo libseccomp 0.4.0 error/tests/test_msg().() { |
| 308 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 309 | |
| 310 | // Errno |
| 311 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 312 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 313 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 314 | ); |
| 315 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 316 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::ECANCELEDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/ECANCELED.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 317 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ECANCELEDrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ECANCELED#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 318 | ); |
| 319 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 320 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EDOMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EDOM.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 321 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EDOMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EDOM#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 322 | ); |
| 323 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 324 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EEXISTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EEXIST.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 325 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EEXISTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EEXIST#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 326 | ); |
| 327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 328 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EFAULTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EFAULT.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 329 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EFAULTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EFAULT#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 330 | ); |
| 331 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 332 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 333 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EINVALrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EINVAL#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 334 | ); |
| 335 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 336 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::ENOENTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOENT.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 337 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ENOENTrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOENT#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 338 | ); |
| 339 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 340 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::ENOMEMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOMEM.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 341 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ENOMEMrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ENOMEM#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 342 | ); |
| 343 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 344 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP#)).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 345 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EOPNOTSUPPrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EOPNOTSUPP#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().(), |
| 346 | ); |
| 347 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 348 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::ERANGErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ERANGE.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 349 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ERANGErust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ERANGE#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 350 | ); |
| 351 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 352 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::ESRCHrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ESRCH.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 353 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::ESRCHrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#ESRCH#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 354 | ); |
| 355 | |
| 356 | // Common |
| 357 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 358 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 359 | TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG. |
| 360 | ); |
| 361 | |
| 362 | // Source |
| 363 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 364 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source#, null_err).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 365 | NULL_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/NULL_ERR_MSG. |
| 366 | ); |
| 367 | |
| 368 | // SysRawRc |
| 369 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 370 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EPIPErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EPIPE.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 371 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("The system's raw error code({}) was returned", -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EPIPErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EPIPE.) |
| 372 | ); |
| 373 | |
| 374 | // InvalidArch |
| 375 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 376 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(InvalidArchrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidArch#(123)).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 377 | "Parse error by invalid architecture", |
| 378 | ); |
| 379 | |
| 380 | // InvalidAction |
| 381 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 382 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(InvalidActionrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidAction#(123)).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 383 | "Parse error by invalid action", |
| 384 | ); |
| 385 | |
| 386 | // FromStr |
| 387 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 388 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(FromStrrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#FromStr#("SCMP".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 389 | "Error while parsing 'SCMP'", |
| 390 | ); |
| 391 | } |
| 392 | |
| 393 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 394 | fn test_sourcerust-analyzer cargo libseccomp 0.4.0 error/tests/test_source().() { |
| 395 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 396 | |
| 397 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#)) |
| 398 | .sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().() |
| 399 | .is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 400 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 401 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#), null_err) |
| 402 | .sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().() |
| 403 | .is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() |
| 404 | ); |
| 405 | } |
| 406 | |
| 407 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 408 | fn test_with_msgrust-analyzer cargo libseccomp 0.4.0 error/tests/test_with_msg().() { |
| 409 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg().(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG.).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG.); |
| 410 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg().(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG.).sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 411 | } |
| 412 | |
| 413 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 414 | fn test_with_msg_and_sourcerust-analyzer cargo libseccomp 0.4.0 error/tests/test_with_msg_and_source().() { |
| 415 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 416 | |
| 417 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 418 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_msg_and_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg_and_source().(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG., null_err.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[NulError][Clone]clone().()).msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]msg().(), |
| 419 | TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG. |
| 420 | ); |
| 421 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_msg_and_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg_and_source().(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG., null_err) |
| 422 | .sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().() |
| 423 | .is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 424 | } |
| 425 | |
| 426 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 427 | fn test_errnorust-analyzer cargo libseccomp 0.4.0 error/tests/test_errno().() { |
| 428 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 429 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES.).errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]errno().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 430 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES# |
| 431 | ); |
| 432 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(libcrust-analyzer cargo libc 0.2.189 crate/::EBADFDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EBADFD.).errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]errno().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 433 | } |
| 434 | |
| 435 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 436 | fn test_sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/tests/test_sysrawrc().() { |
| 437 | let tests = &[ |
| 438 | // The EBADFD is not handled by SeccompErrno |
| 439 | libcrust-analyzer cargo libc 0.2.189 crate/::EBADFDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EBADFD., |
| 440 | // The following errnos are handled by SeccompErrno |
| 441 | libcrust-analyzer cargo libc 0.2.189 crate/::EACCESrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EACCES., |
| 442 | libcrust-analyzer cargo libc 0.2.189 crate/::ECANCELEDrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/ECANCELED., |
| 443 | libcrust-analyzer cargo libc 0.2.189 crate/::EDOMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EDOM., |
| 444 | libcrust-analyzer cargo libc 0.2.189 crate/::EEXISTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EEXIST., |
| 445 | libcrust-analyzer cargo libc 0.2.189 crate/::EFAULTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EFAULT., |
| 446 | libcrust-analyzer cargo libc 0.2.189 crate/::EINVALrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/EINVAL., |
| 447 | libcrust-analyzer cargo libc 0.2.189 crate/::ENOENTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOENT., |
| 448 | libcrust-analyzer cargo libc 0.2.189 crate/::ENOMEMrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ENOMEM., |
| 449 | libcrust-analyzer cargo libc 0.2.189 crate/::EOPNOTSUPPrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/gnu/b64/x86_64/EOPNOTSUPP., |
| 450 | libcrust-analyzer cargo libc 0.2.189 crate/::ERANGErust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ERANGE., |
| 451 | libcrust-analyzer cargo libc 0.2.189 crate/::ESRCHrust-analyzer cargo libc 0.2.189 unix/linux_like/linux_l4re_shared/ESRCH., |
| 452 | ]; |
| 453 | |
| 454 | for errno in tests { |
| 455 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::from_errnorust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]from_errno().(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i32`][Neg]neg().errno).sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]sysrawrc().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&i32`][Neg]neg().errno); |
| 456 | } |
| 457 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_msgrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_msg().("no errno").sysrawrcrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]sysrawrc().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 458 | } |
| 459 | |
| 460 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 461 | fn test_raw_ffi_valuerust-analyzer cargo libseccomp 0.4.0 error/tests/test_raw_ffi_value().() { |
| 462 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 463 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(InvalidArchrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidArch#(123)).raw_ffi_valuerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]raw_ffi_value().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 464 | 123 |
| 465 | ); |
| 466 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 467 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(InvalidActionrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#InvalidAction#(123)) |
| 468 | .raw_ffi_valuerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]raw_ffi_value().() |
| 469 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 470 | 123 |
| 471 | ); |
| 472 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#("".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())) |
| 473 | .raw_ffi_valuerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]raw_ffi_value().() |
| 474 | .is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 475 | } |
| 476 | |
| 477 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 478 | fn test_fromrust-analyzer cargo libseccomp 0.4.0 error/tests/test_from().() { |
| 479 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 480 | let scmp_err = SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::fromrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][`From<std::ffi::NulError>`]from().(null_err.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[NulError][Clone]clone().()); |
| 481 | |
| 482 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(scmp_err.kindrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#kind., ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source#); |
| 483 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(scmp_err.sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError][Error]source().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), null_err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 484 | } |
| 485 | |
| 486 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 487 | fn test_displayrust-analyzer cargo libseccomp 0.4.0 error/tests/test_display().() { |
| 488 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 489 | |
| 490 | // fmt::Display for SeccompErrno |
| 491 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 492 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#), |
| 493 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 494 | ); |
| 495 | |
| 496 | // Errno without source |
| 497 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 498 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#))), |
| 499 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 500 | ); |
| 501 | // Errno with source |
| 502 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 503 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 504 | "{}", |
| 505 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#), null_err.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[NulError][Clone]clone().()) |
| 506 | ), |
| 507 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 508 | "{} caused by: {}", |
| 509 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().(), |
| 510 | NULL_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/NULL_ERR_MSG. |
| 511 | ) |
| 512 | ); |
| 513 | |
| 514 | // Common without source |
| 515 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 516 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))), |
| 517 | TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG. |
| 518 | ); |
| 519 | // Common with source |
| 520 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 521 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 522 | "{}", |
| 523 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(Commonrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Common#(TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), null_err.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[NulError][Clone]clone().()) |
| 524 | ), |
| 525 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{} caused by: {}", TEST_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_ERR_MSG., NULL_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/NULL_ERR_MSG.) |
| 526 | ); |
| 527 | |
| 528 | // Source |
| 529 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 530 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::Sourcerust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Source#, null_err)), |
| 531 | NULL_ERR_MSGrust-analyzer cargo libseccomp 0.4.0 error/tests/NULL_ERR_MSG. |
| 532 | ); |
| 533 | } |
| 534 | |
| 535 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 536 | fn test_debugrust-analyzer cargo libseccomp 0.4.0 error/tests/test_debug().() { |
| 537 | let null_err = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().(TEST_NULL_STRrust-analyzer cargo libseccomp 0.4.0 error/tests/TEST_NULL_STR.).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 538 | |
| 539 | // Errno without source |
| 540 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 541 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::newrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]new().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#))), |
| 542 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 543 | "Error {{ kind: Errno({}), source: {}, message: \"{}\" }}", |
| 544 | "EACCES", |
| 545 | "None", |
| 546 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 547 | ) |
| 548 | ); |
| 549 | // Errno with source |
| 550 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 551 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 552 | "{:?}", |
| 553 | SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#::with_sourcerust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompError]with_source().(Errnorust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#Errno#(SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#), null_err), |
| 554 | ), |
| 555 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 556 | "Error {{ kind: Errno({}), source: {}, message: \"{}\" }}", |
| 557 | "EACCES", |
| 558 | "Some(NulError(1, [102, 0, 111, 111]))", |
| 559 | SeccompErrnorust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#::EACCESrust-analyzer cargo libseccomp 0.4.0 error/SeccompErrno#EACCES#.strerrorrust-analyzer cargo libseccomp 0.4.0 error/impl#[SeccompErrno]strerror().() |
| 560 | ) |
| 561 | ); |
| 562 | } |
| 563 | } |