Debian Codegraph @

src/io/buf.rs

raw symbols SCIP
1 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/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().;
2
3 use bytesrust-analyzer cargo bytes 1.12.1 crate/::{Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#, Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#};
4 use memchrrust-analyzer cargo memchr 2.8.3 crate/::memchrrust-analyzer cargo memchr 2.8.3 memchr/;
5
6 use craterust-analyzer cargo sqlx-core 0.8.3 crate/::errorrust-analyzer cargo sqlx-core 0.8.3 error/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
7
8 pub trait BufExtrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt#: Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf# {
9 // Read a nul-terminated byte sequence
10 fn get_bytes_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt#get_bytes_nul().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>;
11
12 // Read a byte sequence of the exact length
13 fn get_bytesrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt#get_bytes().(&mut self, len: usize) -> Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#;
14
15 // Read a nul-terminated string
16 fn get_str_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt#get_str_nul().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>;
17
18 // Read a string of the exact length
19 fn get_strrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt#get_str().(&mut self, len: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#>;
20 }
21
22 impl BufExtrust-analyzer cargo sqlx-core 0.8.3 io/buf/BufExt# for Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes# {
23 fn get_bytes_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf/impl#[Bytes][BufExt]get_bytes_nul().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
24 let nul =
25 memchrrust-analyzer cargo memchr 2.8.3 memchr/memchr().(b'\0', self).ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("expected NUL in byte sequence"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
26
27 let v = self.slicerust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]slice().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#nul);
28
29 self.advancerust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes][Buf]advance().(nul 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().1);
30
31 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
32 }
33
34 fn get_bytesrust-analyzer cargo sqlx-core 0.8.3 io/buf/impl#[Bytes][BufExt]get_bytes().(&mut self, len: usize) -> Bytesrust-analyzer cargo bytes 1.12.1 bytes/Bytes# {
35 let v = self.slicerust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes]slice().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len);
36 self.advancerust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes][Buf]advance().(len);
37
38 v
39 }
40
41 fn get_str_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf/impl#[Bytes][BufExt]get_str_nul().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
42 self.get_bytes_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf/impl#[Bytes][BufExt]get_bytes_nul().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]and_then().(|bytes| {
43 from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&bytes)
44 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned#::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().)
45 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("{}", err))
46 })
47 }
48
49 fn get_strrust-analyzer cargo sqlx-core 0.8.3 io/buf/impl#[Bytes][BufExt]get_str().(&mut self, len: usize) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
50 let v = from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&self[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
51 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!("{}", err))
52 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned#::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
53
54 self.advancerust-analyzer cargo bytes 1.12.1 bytes/impl#[Bytes][Buf]advance().(len);
55
56 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v)
57 }
58 }