Debian Codegraph @

src/message/sasl.rs

raw symbols SCIP
1 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::BufMutExtrust-analyzer cargo sqlx-core 0.8.3 io/buf_mut/BufMutExt#;
2 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::messagerust-analyzer cargo sqlx-postgres 0.8.3 message/::{FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#, FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#};
3 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
4 use 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/::Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#;
5
6 pub struct SaslInitialResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#<'a> {
7 pub responserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#response.: &'a str,
8 pub plusrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#plus.: bool,
9 }
10
11 impl SaslInitialResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#<'_> {
12 #[inline(always)]
13 fn selected_mechanismrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`]selected_mechanism().(&self) -> &'static str {
14 if self.plusrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#plus. {
15 "SCRAM-SHA-256-PLUS"
16 } else {
17 "SCRAM-SHA-256"
18 }
19 }
20 }
21
22 impl FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage# for SaslInitialResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#<'_> {
23 const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`][FrontendMessage]FORMAT.: FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat# = FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#::PasswordPolymorphicrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#PasswordPolymorphic#;
24
25 #[inline(always)]
26 fn body_size_hintrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`][FrontendMessage]body_size_hint().(&self) -> Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#<usize> {
27 let mut size = Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#(0);
28
29 size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().self.selected_mechanismrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`]selected_mechanism().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
30 size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().1; // NUL terminator
31
32 size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().4; // response_len
33 size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<usize>`]add_assign().self.responserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#response..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
34
35 size
36 }
37
38 fn encode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`][FrontendMessage]encode_body().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
39 // name of the SASL authentication mechanism that the client selected
40 buf.put_str_nulrust-analyzer cargo sqlx-core 0.8.3 io/buf_mut/impl#[`Vec<u8>`][BufMutExt]put_str_nul().(self.selected_mechanismrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslInitialResponse<'_>`]selected_mechanism().());
41
42 let response_len = i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i32][`TryFrom<usize>`]try_from().(self.responserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#response..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| {
43 err_protocolrust-analyzer cargo sqlx-core 0.8.3 error/err_protocol!!(
44 "SASL Initial Response length too long for protcol: {}",
45 self.responserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#response..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()
46 )
47 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
48
49 buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&response_len.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]to_be_bytes().());
50 buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(self.responserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslInitialResponse#response..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
51
52 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
53 }
54 }
55
56 pub struct SaslResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslResponse#<'a>(pub &'a str);
57
58 impl FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage# for SaslResponserust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslResponse#<'_> {
59 const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslResponse<'_>`][FrontendMessage]FORMAT.: FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat# = FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#::PasswordPolymorphicrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#PasswordPolymorphic#;
60
61 fn body_size_hintrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslResponse<'_>`][FrontendMessage]body_size_hint().(&self) -> Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#<usize> {
62 Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#(self.0rust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslResponse#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().())
63 }
64
65 fn encode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/impl#[`SaslResponse<'_>`][FrontendMessage]encode_body().(&self, buf: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
66 buf.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<&'a T>`]extend().(self.0rust-analyzer cargo sqlx-postgres 0.8.3 message/sasl/SaslResponse#0..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().());
67 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
68 }
69 }