| 1 | //! Contains UTF-8 validation implementations. |
| 2 | |
| 3 | type Utf8ErrorCompatrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorCompat# = craterust-analyzer cargo simdutf8 0.1.5 crate/::compatrust-analyzer cargo simdutf8 0.1.5 compat/::Utf8Errorrust-analyzer cargo simdutf8 0.1.5 compat/Utf8Error#; |
| 4 | type Utf8ErrorBasicrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorBasic# = craterust-analyzer cargo simdutf8 0.1.5 crate/::basicrust-analyzer cargo simdutf8 0.1.5 basic/::Utf8Errorrust-analyzer cargo simdutf8 0.1.5 basic/Utf8Error#; |
| 5 | |
| 6 | #[allow(unused_macros)] |
| 7 | #[macro_use] |
| 8 | mod algorithmrust-analyzer cargo simdutf8 0.1.5 implementation/algorithm/; |
| 9 | |
| 10 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) mod helpersrust-analyzer cargo simdutf8 0.1.5 implementation/helpers/; |
| 11 | |
| 12 | // UTF-8 validation function types |
| 13 | |
| 14 | #[allow(dead_code)] |
| 15 | type ValidateUtf8Fnrust-analyzer cargo simdutf8 0.1.5 implementation/ValidateUtf8Fn# = unsafe fn(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorBasicrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorBasic#>; |
| 16 | |
| 17 | #[allow(dead_code)] |
| 18 | type ValidateUtf8CompatFnrust-analyzer cargo simdutf8 0.1.5 implementation/ValidateUtf8CompatFn# = unsafe fn(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorCompatrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorCompat#>; |
| 19 | |
| 20 | // x86 implementation |
| 21 | |
| 22 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 23 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) mod x86rust-analyzer cargo simdutf8 0.1.5 implementation/x86/; |
| 24 | |
| 25 | /// Fn needed instead of re-import, otherwise not inlined in non-std case |
| 26 | #[allow(clippy::inline_always)] |
| 27 | #[inline(always)] |
| 28 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 29 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) unsafe fn validate_utf8_basicrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_basic().(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorBasicrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorBasic#> { |
| 30 | x86rust-analyzer cargo simdutf8 0.1.5 implementation/x86/::validate_utf8_basicrust-analyzer cargo simdutf8 0.1.5 implementation/x86/validate_utf8_basic().(input) |
| 31 | } |
| 32 | |
| 33 | /// Fn needed instead of re-import, otherwise not inlined in non-std case |
| 34 | #[allow(clippy::inline_always)] |
| 35 | #[inline(always)] |
| 36 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
| 37 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) unsafe fn validate_utf8_compatrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_compat().(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorCompatrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorCompat#> { |
| 38 | x86rust-analyzer cargo simdutf8 0.1.5 implementation/x86/::validate_utf8_compatrust-analyzer cargo simdutf8 0.1.5 implementation/x86/validate_utf8_compat().(input) |
| 39 | } |
| 40 | |
| 41 | // aarch64 implementation |
| 42 | |
| 43 | #[cfg(target_arch = "aarch64")] |
| 44 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) mod aarch64; |
| 45 | |
| 46 | #[cfg(target_arch = "aarch64")] |
| 47 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use aarch64::validate_utf8_basic; |
| 48 | |
| 49 | #[cfg(target_arch = "aarch64")] |
| 50 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use aarch64::validate_utf8_compat; |
| 51 | |
| 52 | // wasm32 implementation |
| 53 | |
| 54 | #[cfg(target_arch = "wasm32")] |
| 55 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) mod wasm32; |
| 56 | |
| 57 | #[cfg(target_arch = "wasm32")] |
| 58 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use wasm32::validate_utf8_basic; |
| 59 | |
| 60 | #[cfg(target_arch = "wasm32")] |
| 61 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use wasm32::validate_utf8_compat; |
| 62 | |
| 63 | // fallback for unsupported architectures |
| 64 | |
| 65 | #[cfg(not(any( |
| 66 | target_arch = "x86", |
| 67 | target_arch = "x86_64", |
| 68 | target_arch = "aarch64", |
| 69 | target_arch = "wasm32" |
| 70 | )))] |
| 71 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use validate_utf8_basic_fallbackrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_basic_fallback(). as validate_utf8_basicrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_basic_fallback().; |
| 72 | |
| 73 | #[cfg(not(any( |
| 74 | target_arch = "x86", |
| 75 | target_arch = "x86_64", |
| 76 | target_arch = "aarch64", |
| 77 | target_arch = "wasm32" |
| 78 | )))] |
| 79 | pub(superrust-analyzer cargo simdutf8 0.1.5 crate/) use validate_utf8_compat_fallbackrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_compat_fallback(). as validate_utf8_compatrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_compat_fallback().; |
| 80 | |
| 81 | // fallback method implementations |
| 82 | |
| 83 | #[inline] |
| 84 | #[allow(dead_code)] |
| 85 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) fn validate_utf8_basic_fallbackrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_basic_fallback().(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorBasicrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorBasic#> { |
| 86 | match corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(input) { |
| 87 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 88 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Utf8ErrorBasicrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorBasic# {}), |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | #[inline] |
| 93 | #[allow(dead_code)] |
| 94 | pub(craterust-analyzer cargo simdutf8 0.1.5 crate/) fn validate_utf8_compat_fallbackrust-analyzer cargo simdutf8 0.1.5 implementation/validate_utf8_compat_fallback().(input: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Utf8ErrorCompatrust-analyzer cargo simdutf8 0.1.5 implementation/Utf8ErrorCompat#> { |
| 95 | helpersrust-analyzer cargo simdutf8 0.1.5 implementation/helpers/::validate_utf8_at_offsetrust-analyzer cargo simdutf8 0.1.5 implementation/helpers/validate_utf8_at_offset().(input, 0) |
| 96 | } |