| 1 | // SPDX-License-Identifier: Apache-2.0 or MIT |
| 2 | // |
| 3 | // Copyright 2021 Sony Group Corporation |
| 4 | // |
| 5 | |
| 6 | use craterust-analyzer cargo libseccomp 0.4.0 crate/::errorrust-analyzer cargo libseccomp 0.4.0 error/::ErrorKindrust-analyzer cargo libseccomp 0.4.0 error/ErrorKind#::*; |
| 7 | use craterust-analyzer cargo libseccomp 0.4.0 crate/::errorrust-analyzer cargo libseccomp 0.4.0 error/::{Resultrust-analyzer cargo libseccomp 0.4.0 error/Result#, SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#}; |
| 8 | use libseccomp_sysrust-analyzer cargo libseccomp-sys 0.3.0 crate/::*; |
| 9 | use 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/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#; |
| 10 | |
| 11 | /// Represents a CPU architecture. |
| 12 | /// Seccomp can restrict syscalls on a per-architecture basis. |
| 13 | #[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:)] |
| 14 | #[non_exhaustive] |
| 15 | pub enum ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch# { |
| 16 | /// The native architecture token |
| 17 | Nativerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Native#, |
| 18 | /// The x86 (32-bit) architecture token |
| 19 | X86rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X86#, |
| 20 | /// The x86-64 (64-bit) architecture token |
| 21 | X8664rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X8664#, |
| 22 | /// The x32 (32-bit x86_64) architecture token |
| 23 | X32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X32#, |
| 24 | /// The ARM architecture token |
| 25 | Armrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Arm#, |
| 26 | /// The AARCH64 architecture token |
| 27 | Aarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Aarch64#, |
| 28 | /// The LoongArch architecture token |
| 29 | Loongarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Loongarch64#, |
| 30 | /// The Motorola 68000 architecture token |
| 31 | M68krust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#M68k#, |
| 32 | /// The MIPS architecture token |
| 33 | Mipsrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips#, |
| 34 | /// The MIPS (64-bit) architecture token |
| 35 | Mips64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64#, |
| 36 | /// The MIPS64N32 architecture token |
| 37 | Mips64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64N32#, |
| 38 | /// The MIPSEL architecture token |
| 39 | Mipselrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel#, |
| 40 | /// The MIPSEL (64-bit) architecture token |
| 41 | Mipsel64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64#, |
| 42 | /// The MIPSEL64N32 architecture token |
| 43 | Mipsel64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64N32#, |
| 44 | /// The PowerPC architecture token |
| 45 | Ppcrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc#, |
| 46 | /// The PowerPC (64-bit) architecture token |
| 47 | Ppc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64#, |
| 48 | /// The PowerPC64LE architecture token |
| 49 | Ppc64Lerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64Le#, |
| 50 | /// The S390 architecture token |
| 51 | S390rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390#, |
| 52 | /// The S390X architecture token |
| 53 | S390Xrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390X#, |
| 54 | /// The PA-RISC hppa architecture token |
| 55 | Pariscrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc#, |
| 56 | /// The PA-RISC (64-bit) hppa architecture token |
| 57 | Parisc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc64#, |
| 58 | /// The RISC-V architecture token |
| 59 | Riscv64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Riscv64#, |
| 60 | /// The SuperH (big-endian) architecture token |
| 61 | Shebrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sheb#, |
| 62 | /// The SuperH (little-endian) architecture token |
| 63 | Shrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sh#, |
| 64 | } |
| 65 | |
| 66 | impl ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch# { |
| 67 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn to_sysrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]to_sys().(self) -> u32 { |
| 68 | match self { |
| 69 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Nativerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Native# => SCMP_ARCH_NATIVErust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_NATIVE., |
| 70 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X86rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X86# => SCMP_ARCH_X86rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X86., |
| 71 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X8664rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X8664# => SCMP_ARCH_X86_64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X86_64., |
| 72 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X32# => SCMP_ARCH_X32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X32., |
| 73 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Armrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Arm# => SCMP_ARCH_ARMrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_ARM., |
| 74 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Aarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Aarch64# => SCMP_ARCH_AARCH64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_AARCH64., |
| 75 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Loongarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Loongarch64# => SCMP_ARCH_LOONGARCH64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_LOONGARCH64., |
| 76 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::M68krust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#M68k# => SCMP_ARCH_M68Krust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_M68K., |
| 77 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips# => SCMP_ARCH_MIPSrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS., |
| 78 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mips64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64# => SCMP_ARCH_MIPS64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS64., |
| 79 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mips64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64N32# => SCMP_ARCH_MIPS64N32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS64N32., |
| 80 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipselrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel# => SCMP_ARCH_MIPSELrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL., |
| 81 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsel64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64# => SCMP_ARCH_MIPSEL64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL64., |
| 82 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsel64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64N32# => SCMP_ARCH_MIPSEL64N32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL64N32., |
| 83 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppcrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc# => SCMP_ARCH_PPCrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC., |
| 84 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64# => SCMP_ARCH_PPC64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC64., |
| 85 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppc64Lerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64Le# => SCMP_ARCH_PPC64LErust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC64LE., |
| 86 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::S390rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390# => SCMP_ARCH_S390rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_S390., |
| 87 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::S390Xrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390X# => SCMP_ARCH_S390Xrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_S390X., |
| 88 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Pariscrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc# => SCMP_ARCH_PARISCrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PARISC., |
| 89 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Parisc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc64# => SCMP_ARCH_PARISC64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PARISC64., |
| 90 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Riscv64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Riscv64# => SCMP_ARCH_RISCV64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_RISCV64., |
| 91 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Shebrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sheb# => SCMP_ARCH_SHEBrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_SHEB., |
| 92 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Shrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sh# => SCMP_ARCH_SHrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_SH., |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | pub(craterust-analyzer cargo libseccomp 0.4.0 crate/) fn from_sysrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]from_sys().(arch: u32) -> Resultrust-analyzer cargo libseccomp 0.4.0 error/Result#<Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]> { |
| 97 | match arch { |
| 98 | SCMP_ARCH_NATIVErust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_NATIVE. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Nativerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Native#), |
| 99 | SCMP_ARCH_X86rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X86. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X86rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X86#), |
| 100 | SCMP_ARCH_X86_64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X86_64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X8664rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X8664#), |
| 101 | SCMP_ARCH_X32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_X32. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::X32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X32#), |
| 102 | SCMP_ARCH_ARMrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_ARM. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Armrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Arm#), |
| 103 | SCMP_ARCH_AARCH64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_AARCH64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Aarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Aarch64#), |
| 104 | SCMP_ARCH_LOONGARCH64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_LOONGARCH64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Loongarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Loongarch64#), |
| 105 | SCMP_ARCH_M68Krust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_M68K. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::M68krust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#M68k#), |
| 106 | SCMP_ARCH_MIPSrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips#), |
| 107 | SCMP_ARCH_MIPS64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mips64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64#), |
| 108 | SCMP_ARCH_MIPS64N32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPS64N32. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mips64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64N32#), |
| 109 | SCMP_ARCH_MIPSELrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipselrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel#), |
| 110 | SCMP_ARCH_MIPSEL64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsel64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64#), |
| 111 | SCMP_ARCH_MIPSEL64N32rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_MIPSEL64N32. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Mipsel64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64N32#), |
| 112 | SCMP_ARCH_PPCrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppcrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc#), |
| 113 | SCMP_ARCH_PPC64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64#), |
| 114 | SCMP_ARCH_PPC64LErust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PPC64LE. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Ppc64Lerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64Le#), |
| 115 | SCMP_ARCH_S390rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_S390. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::S390rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390#), |
| 116 | SCMP_ARCH_S390Xrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_S390X. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::S390Xrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390X#), |
| 117 | SCMP_ARCH_PARISCrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PARISC. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Pariscrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc#), |
| 118 | SCMP_ARCH_PARISC64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_PARISC64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Parisc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc64#), |
| 119 | SCMP_ARCH_RISCV64rust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_RISCV64. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Riscv64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Riscv64#), |
| 120 | SCMP_ARCH_SHEBrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_SHEB. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Shebrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sheb#), |
| 121 | SCMP_ARCH_SHrust-analyzer cargo libseccomp-sys 0.3.0 SCMP_ARCH_SH. => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::Shrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sh#), |
| 122 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(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#(arch))), |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | /// Returns the system's native architecture. |
| 127 | /// |
| 128 | /// This function corresponds to |
| 129 | /// [`seccomp_arch_native`](https://man7.org/linux/man-pages/man3/seccomp_arch_native.3.html). |
| 130 | /// |
| 131 | /// # Panics |
| 132 | /// |
| 133 | /// This function panics if it can not get the native architecture. |
| 134 | pub fn nativerust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]native().() -> Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch] { |
| 135 | Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]::from_sysrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]from_sys().(unsafe { seccomp_arch_nativerust-analyzer cargo libseccomp-sys 0.3.0 seccomp_arch_native().() }).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Could not get native architecture") |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch# { |
| 140 | type Errrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]Err# = SeccompErrorrust-analyzer cargo libseccomp 0.4.0 error/SeccompError#; |
| 141 | |
| 142 | /// Converts string seccomp architecture to `ScmpArch`. |
| 143 | /// |
| 144 | /// # Arguments |
| 145 | /// |
| 146 | /// * `arch` - A string architecture, e.g. `SCMP_ARCH_*`. |
| 147 | /// |
| 148 | /// See the [`seccomp_arch_add(3)`] man page for details on valid architecture values. |
| 149 | /// |
| 150 | /// [`seccomp_arch_add(3)`]: https://www.man7.org/linux/man-pages/man3/seccomp_arch_add.3.html |
| 151 | /// |
| 152 | /// # Errors |
| 153 | /// |
| 154 | /// If an invalid architecture is specified, an error will be returned. |
| 155 | fn from_strrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]from_str().(arch: &str) -> Resultrust-analyzer cargo libseccomp 0.4.0 error/Result#<Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]> { |
| 156 | match arch { |
| 157 | "SCMP_ARCH_NATIVE" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Nativerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Native#), |
| 158 | "SCMP_ARCH_X86" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::X86rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X86#), |
| 159 | "SCMP_ARCH_X86_64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::X8664rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X8664#), |
| 160 | "SCMP_ARCH_X32" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::X32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X32#), |
| 161 | "SCMP_ARCH_ARM" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Armrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Arm#), |
| 162 | "SCMP_ARCH_AARCH64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Aarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Aarch64#), |
| 163 | "SCMP_ARCH_LOONGARCH64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Loongarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Loongarch64#), |
| 164 | "SCMP_ARCH_M68K" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::M68krust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#M68k#), |
| 165 | "SCMP_ARCH_MIPS" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mipsrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips#), |
| 166 | "SCMP_ARCH_MIPS64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mips64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64#), |
| 167 | "SCMP_ARCH_MIPS64N32" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mips64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64N32#), |
| 168 | "SCMP_ARCH_MIPSEL" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mipselrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel#), |
| 169 | "SCMP_ARCH_MIPSEL64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mipsel64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64#), |
| 170 | "SCMP_ARCH_MIPSEL64N32" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Mipsel64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64N32#), |
| 171 | "SCMP_ARCH_PPC" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Ppcrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc#), |
| 172 | "SCMP_ARCH_PPC64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Ppc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64#), |
| 173 | "SCMP_ARCH_PPC64LE" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Ppc64Lerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64Le#), |
| 174 | "SCMP_ARCH_S390" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::S390rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390#), |
| 175 | "SCMP_ARCH_S390X" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::S390Xrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390X#), |
| 176 | "SCMP_ARCH_PARISC" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Pariscrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc#), |
| 177 | "SCMP_ARCH_PARISC64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Parisc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc64#), |
| 178 | "SCMP_ARCH_RISCV64" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Riscv64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Riscv64#), |
| 179 | "SCMP_ARCH_SHEB" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Shebrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sheb#), |
| 180 | "SCMP_ARCH_SH" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch][FromStr]::Shrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sh#), |
| 181 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(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#(arch.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()))), |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | #[cfg(test)] |
| 187 | mod testsrust-analyzer cargo libseccomp 0.4.0 arch/tests/ { |
| 188 | use superrust-analyzer cargo libseccomp 0.4.0 arch/::*; |
| 189 | |
| 190 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 191 | fn test_parse_archrust-analyzer cargo libseccomp 0.4.0 arch/tests/test_parse_arch().() { |
| 192 | let test_data = &[ |
| 193 | ("SCMP_ARCH_NATIVE", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Nativerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Native#), |
| 194 | ("SCMP_ARCH_X86", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::X86rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X86#), |
| 195 | ("SCMP_ARCH_X86_64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::X8664rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X8664#), |
| 196 | ("SCMP_ARCH_X32", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::X32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#X32#), |
| 197 | ("SCMP_ARCH_ARM", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Armrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Arm#), |
| 198 | ("SCMP_ARCH_AARCH64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Aarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Aarch64#), |
| 199 | ("SCMP_ARCH_LOONGARCH64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Loongarch64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Loongarch64#), |
| 200 | ("SCMP_ARCH_M68K", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::M68krust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#M68k#), |
| 201 | ("SCMP_ARCH_MIPS", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mipsrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips#), |
| 202 | ("SCMP_ARCH_MIPS64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mips64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64#), |
| 203 | ("SCMP_ARCH_MIPS64N32", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mips64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mips64N32#), |
| 204 | ("SCMP_ARCH_MIPSEL", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mipselrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel#), |
| 205 | ("SCMP_ARCH_MIPSEL64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mipsel64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64#), |
| 206 | ("SCMP_ARCH_MIPSEL64N32", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Mipsel64N32rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Mipsel64N32#), |
| 207 | ("SCMP_ARCH_PPC", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Ppcrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc#), |
| 208 | ("SCMP_ARCH_PPC64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Ppc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64#), |
| 209 | ("SCMP_ARCH_PPC64LE", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Ppc64Lerust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Ppc64Le#), |
| 210 | ("SCMP_ARCH_S390", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::S390rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390#), |
| 211 | ("SCMP_ARCH_S390X", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::S390Xrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#S390X#), |
| 212 | ("SCMP_ARCH_PARISC", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Pariscrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc#), |
| 213 | ("SCMP_ARCH_PARISC64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Parisc64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Parisc64#), |
| 214 | ("SCMP_ARCH_RISCV64", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Riscv64rust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Riscv64#), |
| 215 | ("SCMP_ARCH_SHEB", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Shebrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sheb#), |
| 216 | ("SCMP_ARCH_SH", ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::Shrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#Sh#), |
| 217 | ]; |
| 218 | |
| 219 | for data in test_data { |
| 220 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 221 | ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::from_sysrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]from_sys().(ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::from_str(data.0).unwrap().to_sys()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 222 | data.1 |
| 223 | ); |
| 224 | } |
| 225 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::from_str("SCMP_INVALID_FLAG").is_err()); |
| 226 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(ScmpArchrust-analyzer cargo libseccomp 0.4.0 arch/ScmpArch#::from_sysrust-analyzer cargo libseccomp 0.4.0 arch/impl#[ScmpArch]from_sys().(1).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 227 | } |
| 228 | } |