| 1 | mod child_entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/child_entry/; |
| 2 | mod entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/entry/; |
| 3 | mod headerrust-analyzer cargo udevrs 0.4.0 hwdb/trie/header/; |
| 4 | mod noderust-analyzer cargo udevrs 0.4.0 hwdb/trie/node/; |
| 5 | mod value_entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/value_entry/; |
| 6 | |
| 7 | use craterust-analyzer cargo udevrs 0.4.0 crate/::{Errorrust-analyzer cargo udevrs 0.4.0 error/Error#, Resultrust-analyzer cargo udevrs 0.4.0 error/Result#}; |
| 8 | pub use child_entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/child_entry/::*; |
| 9 | pub use entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/entry/::*; |
| 10 | pub use headerrust-analyzer cargo udevrs 0.4.0 hwdb/trie/header/::*; |
| 11 | pub use noderust-analyzer cargo udevrs 0.4.0 hwdb/trie/node/::*; |
| 12 | pub use value_entryrust-analyzer cargo udevrs 0.4.0 hwdb/trie/value_entry/::*; |
| 13 | |
| 14 | /// Hardware database signature. |
| 15 | pub const HWDB_SIGrust-analyzer cargo udevrs 0.4.0 hwdb/trie/HWDB_SIG.: [u8; 8] = [b'K', b'S', b'L', b'P', b'H', b'H', b'R', b'H']; |
| 16 | /// Hardware database signature (string representation). |
| 17 | pub const HWDB_SIG_STRrust-analyzer cargo udevrs 0.4.0 hwdb/trie/HWDB_SIG_STR.: &str = "KSLPHHRH"; |
| 18 | |
| 19 | /// Parses a string from the HWDB buffer. |
| 20 | pub fn trie_stringrust-analyzer cargo udevrs 0.4.0 hwdb/trie/trie_string().(hwdb_buf: &[u8], offset: usize) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&str> { |
| 21 | let buf_len = hwdb_buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 22 | if (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#buf_len).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`Range<Idx>`]contains().(&offset) { |
| 23 | let str_end = hwdb_buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 24 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 25 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&b'\0' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&b'\n') |
| 26 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|end| offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().end) |
| 27 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(buf_len); |
| 28 | |
| 29 | 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/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&hwdb_buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#str_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().) |
| 30 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevHwdbrust-analyzer cargo udevrs 0.4.0 error/Error#UdevHwdb#("failed to parse utf-8 trie_string".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 31 | } else { |
| 32 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevHwdbrust-analyzer cargo udevrs 0.4.0 error/Error#UdevHwdb#("invalid trie_string offset".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 33 | } |
| 34 | } |