Debian Codegraph @

src/message/execute.rs

raw symbols SCIP
1 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#;
2
3 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
4
5 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::{PgBufMutExtrust-analyzer cargo sqlx-postgres 0.8.3 io/buf_mut/PgBufMutExt#, PortalIdrust-analyzer cargo sqlx-postgres 0.8.3 io/PortalId#};
6 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#};
7
8 pub struct Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute# {
9 /// The id of the portal to execute.
10 pub portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#portal.: PortalIdrust-analyzer cargo sqlx-postgres 0.8.3 io/PortalId#,
11
12 /// Maximum number of rows to return, if portal contains a query
13 /// that returns rows (ignored otherwise). Zero denotes “no limit”.
14 pub limitrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#limit.: u32,
15 }
16
17 impl FrontendMessagerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage# for Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute# {
18 const FORMATrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/impl#[Execute][FrontendMessage]FORMAT.: FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat# = FrontendMessageFormatrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#::Executerust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessageFormat#Execute#;
19
20 fn body_size_hintrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/impl#[Execute][FrontendMessage]body_size_hint().(&self) -> Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#<usize> {
21 let mut size = Saturatingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/Saturating#(0);
22
23 size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/saturating/impl#[`Saturating<usize>`][`AddAssign<Self>`]add_assign().self.portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#portal..name_lenrust-analyzer cargo sqlx-postgres 0.8.3 io/impl#[PortalId]name_len().();
24 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().2; // limit
25
26 size
27 }
28
29 fn encode_bodyrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/impl#[Execute][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#> {
30 buf.put_portal_namerust-analyzer cargo sqlx-postgres 0.8.3 io/buf_mut/impl#[`Vec<u8>`][PgBufMutExt]put_portal_name().(self.portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#portal.);
31 buf.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<&'a T>`]extend().(&self.limitrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#limit..to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().());
32
33 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
34 }
35 }
36
37 #[cfg(test)]
38 mod testsrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/ {
39 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::iorust-analyzer cargo sqlx-postgres 0.8.3 io/::PortalIdrust-analyzer cargo sqlx-postgres 0.8.3 io/PortalId#;
40 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#;
41
42 use superrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/::Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#;
43
44 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
45 fn test_encode_execute_named_portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/test_encode_execute_named_portal().() {
46 const EXPECTEDrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/EXPECTED.: &[u8] = b"E\0\0\0\x1Asqlx_p_1234567890\0\0\0\0\x02";
47
48 let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
49 let m = Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute# {
50 portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#portal.: PortalIdrust-analyzer cargo sqlx-postgres 0.8.3 io/PortalId#::TEST_VALrust-analyzer cargo sqlx-postgres 0.8.3 io/impl#[PortalId]TEST_VAL.,
51 limitrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#limit.: 2,
52 };
53
54 m.encode_msgrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#encode_msg().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
55
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, EXPECTEDrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/EXPECTED.);
57 }
58
59 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
60 fn test_encode_execute_unnamed_portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/test_encode_execute_unnamed_portal().() {
61 const EXPECTEDrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/EXPECTED.: &[u8] = b"E\0\0\0\x09\0\x49\x96\x02\xD2";
62
63 let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
64 let m = Executerust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute# {
65 portalrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#portal.: PortalIdrust-analyzer cargo sqlx-postgres 0.8.3 io/PortalId#::UNNAMEDrust-analyzer cargo sqlx-postgres 0.8.3 io/impl#[PortalId]UNNAMED.,
66 limitrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/Execute#limit.: 1234567890,
67 };
68
69 m.encode_msgrust-analyzer cargo sqlx-postgres 0.8.3 message/FrontendMessage#encode_msg().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
70
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buf, EXPECTEDrust-analyzer cargo sqlx-postgres 0.8.3 message/execute/tests/EXPECTED.);
72 }
73 }