Debian Codegraph @

src/types/cube.rs

raw symbols SCIP
1 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::decoderust-analyzer cargo sqlx-core 0.8.3 decode/::Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#;
2 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::encoderust-analyzer cargo sqlx-core 0.8.3 encode/::{Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#, IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#};
3 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::errorrust-analyzer cargo sqlx-postgres 0.8.3 error/::BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#;
4 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::typesrust-analyzer cargo sqlx-postgres 0.8.3 types/::Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#;
5 use craterust-analyzer cargo sqlx-postgres 0.8.3 crate/::{PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#, PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType#, PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#, PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#, PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#};
6 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::bytesrust-analyzer cargo bytes 1.12.1 crate/::Bufrust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#;
7 use sqlx_corerust-analyzer cargo sqlx-core 0.8.3 crate/::Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
9 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/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
10
11 const BYTE_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/BYTE_WIDTH.: usize = 8;
12
13 /// <https://github.com/postgres/postgres/blob/e3ec9dc1bf4983fcedb6f43c71ea12ee26aefc7a/contrib/cube/cubedata.h#L7>
14 const MAX_DIMENSIONSrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/MAX_DIMENSIONS.: usize = 100;
15
16 const IS_POINT_FLAGrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/IS_POINT_FLAG.: u32 = 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shl<i32>`]shl().31;
17
18 // FIXME(breaking): these variants are confusingly named and structured
19 // consider changing them or making this an opaque wrapper around `Vec<f64>`
20 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
21 pub enum PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
22 /// A one-dimensional point.
23 // FIXME: `Point1D(f64)
24 Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(f64),
25 /// An N-dimensional point ("represented internally as a zero-volume cube").
26 // FIXME: `PointND(f64)`
27 ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f64>),
28
29 /// A one-dimensional interval with starting and ending points.
30 // FIXME: `Interval1D { start: f64, end: f64 }`
31 OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(f64, f64),
32
33 // FIXME: add `Cube3D { lower_left: [f64; 3], upper_right: [f64; 3] }`?
34 /// An N-dimensional cube with points representing lower-left and upper-right corners, respectively.
35 // FIXME: CubeND { lower_left: Vec<f64>, upper_right: Vec<f64> }`
36 MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f64>>),
37 }
38
39 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
40 struct Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
41 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.: usize,
42 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.: bool,
43 }
44
45 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, thiserrorrust-analyzer cargo thiserror 2.0.20 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.20 Error:)]
46 #[error("error decoding CUBE (is_point: {is_point}, dimensions: {dimensions})")]
47 struct DecodeErrorrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError# {
48 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#is_point.: bool,
49 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#dimensions.: usize,
50 messagerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
51 }
52
53 impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
54 fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
55 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::with_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]with_name().("cube")
56 }
57 }
58
59 impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
60 fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# {
61 PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::with_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]with_name().("_cube")
62 }
63 }
64
65 impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
66 fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Decode<'r, Postgres>`]decode().(value: PgValueRefrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueRef#<'r>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Decode<'r, Postgres>`], Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>> {
67 match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() {
68 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Textrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Text# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().(value.as_strrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_str().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
69 PgValueFormatrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#::Binaryrust-analyzer cargo sqlx-postgres 0.8.3 value/PgValueFormat#Binary# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(value.as_bytesrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]as_bytes().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
70 }
71 }
72 }
73
74 impl<'q> Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'q, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
75 fn producesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Encode<'q, Postgres>`]produces().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#> {
76 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo#::with_namerust-analyzer cargo sqlx-postgres 0.8.3 type_info/impl#[PgTypeInfo]with_name().("cube"))
77 }
78
79 fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Encode<'q, Postgres>`]encode_by_ref().(&self, buf: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
80 self.serializerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
81 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(IsNullrust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#::Norust-analyzer cargo sqlx-core 0.8.3 encode/IsNull#No#)
82 }
83
84 fn size_hintrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][`Encode<'q, Postgres>`]size_hint().(&self) -> usize {
85 self.headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]header().().encoded_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]encoded_size().()
86 }
87 }
88
89 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
90 type Errrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]Err# = Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#;
91
92 fn from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr], Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
93 let content = s
94 .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().('(')
95 .trim_start_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_start_matches().('[')
96 .trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().(')')
97 .trim_end_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_end_matches().(']')
98 .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(' ', "");
99
100 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().content.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('(') && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().content.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(',') {
101 return parse_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_point().(&content);
102 }
103
104 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().content.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().("),(") {
105 return parse_zero_volumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_zero_volume().(&content);
106 }
107
108 let point_vecs = content.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().("),(").collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>>();
109 if point_vecs.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().2 && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().point_vecs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|pv| pv.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(',')) {
110 return parse_one_dimensional_intervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_one_dimensional_interval().(point_vecs);
111 }
112
113 parse_multidimensional_intervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_multidimensional_interval().(point_vecs)
114 }
115 }
116
117 impl PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube# {
118 fn headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]header().(&self) -> Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
119 match self {
120 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(..) => Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
121 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.: true,
122 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.: 1,
123 },
124 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(values) => Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
125 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.: true,
126 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.: values.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(),
127 },
128 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(..) => Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
129 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.: false,
130 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.: 1,
131 },
132 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(multi_values) => Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
133 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.: false,
134 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.: multi_values.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|arr| arr.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0),
135 },
136 }
137 }
138
139 fn from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(mut bytes: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube], BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> {
140 let header = Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#::try_readrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]try_read().(&mut bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
141
142 if bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().header.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().() {
143 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DecodeErrorrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#::newrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[DecodeError]new().(
144 &header,
145 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
146 "expected {} bytes after header, got {}",
147 header.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().(),
148 bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
149 ),
150 )
151 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
152 }
153
154 match (header.is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point., header.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.) {
155 (true, 1) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().())),
156 (true, _) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(
157 read_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/read_vec().(&mut bytes).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| DecodeErrorrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#::newrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[DecodeError]new().(&header, e))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
158 )),
159 (false, 1) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(
160 bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().(),
161 bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().(),
162 )),
163 (false, _) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(read_cuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/read_cube().(&header, bytes)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)),
164 }
165 }
166
167 fn serializerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize().(&self, buff: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> 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#> {
168 let header = self.headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]header().();
169
170 buff.reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve().(header.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().());
171
172 header.try_writerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]try_write().(buff)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
173
174 match self {
175 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(value) => {
176 buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&value.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().());
177 }
178 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(values) => {
179 buff.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(values.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|v| v.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().()));
180 }
181 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(x, y) => {
182 buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&x.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().());
183 buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&y.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().());
184 }
185 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(multi_values) => {
186 if multi_values.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().2 {
187 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid CUBE value: {self:?}"));
188 }
189
190 buff.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(
191 multi_values
192 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
193 .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|point| point.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|scalar| scalar.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().())),
194 );
195 }
196 };
197 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
198 }
199
200 #[cfg(test)]
201 fn serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> {
202 let mut buff = PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#::defaultrust-analyzer cargo sqlx-postgres 0.8.3 arguments/impl#[PgArgumentBuffer][Default]default().();
203 self.serializerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize().(&mut buff).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
204 buff.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()
205 }
206 }
207
208 fn read_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/read_vec().(bytes: &mut &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f64>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
209 if bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().BYTE_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/BYTE_WIDTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 {
210 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
211 "data length not divisible by {BYTE_WIDTH}: {}",
212 bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
213 ));
214 }
215
216 let mut out = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().BYTE_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/BYTE_WIDTH.);
217
218 while bytes.has_remainingrust-analyzer cargo bytes 1.12.1 buf/buf_impl/impl#[`&mut T`][Buf]has_remaining().() {
219 out.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().());
220 }
221
222 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out)
223 }
224
225 fn read_cuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/read_cube().(header: &Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#, mut bytes: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f64>>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
226 if bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().header.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().() {
227 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
228 "expected {} bytes, got {}",
229 header.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().(),
230 bytes.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
231 ));
232 }
233
234 let mut out = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(2);
235
236 // Expecting exactly 2 N-dimensional points
237 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2 {
238 let mut point = 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().();
239
240 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#header.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions. {
241 point.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().());
242 }
243
244 out.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(point);
245 }
246
247 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(out)
248 }
249
250 fn parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(s: &str, error_msg: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
251 s.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Decoderust-analyzer cargo sqlx-core 0.8.3 error/Error#Decode#(error_msg.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
252 }
253
254 fn parse_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_point().(str: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
255 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(
256 str,
257 "Failed to parse point",
258 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
259 }
260
261 fn parse_zero_volumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_zero_volume().(content: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
262 content
263 .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',')
264 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(p, "Failed to parse into zero-volume cube"))
265 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()
266 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#)
267 }
268
269 fn parse_one_dimensional_intervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_one_dimensional_interval().(point_vecs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
270 let x = parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(
271 &remove_parenthesesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/remove_parentheses().(point_vecs.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Decoderust-analyzer cargo sqlx-core 0.8.3 error/Error#Decode#(
272 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Could not decode cube interval x: {:?}", point_vecs).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
273 ))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
274 "Failed to parse X in one-dimensional interval",
275 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
276 let y = parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(
277 &remove_parenthesesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/remove_parentheses().(point_vecs.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(1).ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#::Decoderust-analyzer cargo sqlx-core 0.8.3 error/Error#Decode#(
278 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Could not decode cube interval y: {:?}", point_vecs).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
279 ))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
280 "Failed to parse Y in one-dimensional interval",
281 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
282 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(x, y))
283 }
284
285 fn parse_multidimensional_intervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_multidimensional_interval().(point_vecs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#, Errorrust-analyzer cargo sqlx-core 0.8.3 error/Error#> {
286 point_vecs
287 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
288 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|&point_vec| {
289 point_vec
290 .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(',')
291 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|point| {
292 parse_float_from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/parse_float_from_str().(
293 &remove_parenthesesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/remove_parentheses().(point),
294 "Failed to parse into multi-dimension cube",
295 )
296 })
297 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()
298 })
299 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>, _>>()
300 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#)
301 }
302
303 fn remove_parenthesesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/remove_parentheses().(s: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
304 s.trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().(|c| c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'(' || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().')').to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
305 }
306
307 impl Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header# {
308 const PACKED_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]PACKED_WIDTH.: usize = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
309
310 fn encoded_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]encoded_size().(&self) -> usize {
311 Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]::PACKED_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]PACKED_WIDTH. 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().self.data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().()
312 }
313
314 fn data_sizerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]data_size().(&self) -> usize {
315 if self.is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point. {
316 self.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().BYTE_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/BYTE_WIDTH.
317 } else {
318 self.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().BYTE_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/BYTE_WIDTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2
319 }
320 }
321
322 fn try_writerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]try_write().(&self, buff: &mut PgArgumentBufferrust-analyzer cargo sqlx-postgres 0.8.3 arguments/PgArgumentBuffer#) -> 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#> {
323 if self.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().MAX_DIMENSIONSrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/MAX_DIMENSIONS. {
324 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
325 "CUBE dimensionality exceeds allowed maximum ({} > {MAX_DIMENSIONS})",
326 self.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.
327 ));
328 }
329
330 // Cannot overflow thanks to the above check.
331 #[allow(clippy::cast_possible_truncation)]
332 let mut packed = self.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions. as u32;
333
334 // https://github.com/postgres/postgres/blob/e3ec9dc1bf4983fcedb6f43c71ea12ee26aefc7a/contrib/cube/cubedata.h#L18-L24
335 if self.is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point. {
336 packed rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOrAssign<Self>`]bitor_assign().IS_POINT_FLAGrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/IS_POINT_FLAG.;
337 }
338
339 buff.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(packed.to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be_bytes().());
340
341 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
342 }
343
344 fn try_readrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]try_read().(buf: &mut &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header], Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
345 if buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]::PACKED_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]PACKED_WIDTH. {
346 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
347 "expected CUBE data to contain at least {} bytes, got {}",
348 Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]::PACKED_WIDTHrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header]PACKED_WIDTH.,
349 buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()
350 ));
351 }
352
353 let packed = buf.get_u32rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_u32().();
354
355 let is_point = packed rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().IS_POINT_FLAGrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/IS_POINT_FLAG. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0;
356 let dimensions = packed rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][Not]not().IS_POINT_FLAGrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/IS_POINT_FLAG.;
357
358 // can only overflow on 16-bit platforms
359 let dimensions = usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<u32>`]try_from().(dimensions)
360 .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
361 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]filter().(|&it| it rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().MAX_DIMENSIONSrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/MAX_DIMENSIONS.)
362 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("received CUBE data with higher than expected dimensionality: {dimensions} (is_point: {is_point})"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
363
364 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[Header] {
365 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.,
366 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.,
367 })
368 }
369 }
370
371 impl DecodeErrorrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError# {
372 fn newrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[DecodeError]new().(header: &Headerrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#, message: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[DecodeError] {
373 DecodeErrorrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError# {
374 is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#is_point.: header.is_pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#is_point.,
375 dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#dimensions.: header.dimensionsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/Header#dimensions.,
376 messagerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/DecodeError#message.,
377 }
378 }
379 }
380
381 #[cfg(test)]
382 mod cube_testsrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ {
383
384 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/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
385
386 use superrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/::PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#;
387
388 const POINT_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/POINT_BYTES.: &[u8] = &[128, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 0];
389 const ZERO_VOLUME_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ZERO_VOLUME_BYTES.: &[u8] = &[
390 128, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 64, 8, 0, 0, 0, 0, 0, 0,
391 ];
392 const ONE_DIMENSIONAL_INTERVAL_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ONE_DIMENSIONAL_INTERVAL_BYTES.: &[u8] = &[
393 0, 0, 0, 1, 64, 28, 0, 0, 0, 0, 0, 0, 64, 32, 0, 0, 0, 0, 0, 0,
394 ];
395 const MULTI_DIMENSION_2_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_2_DIM_BYTES.: &[u8] = &[
396 0, 0, 0, 2, 63, 240, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 64, 8, 0, 0, 0, 0, 0, 0,
397 64, 16, 0, 0, 0, 0, 0, 0,
398 ];
399 const MULTI_DIMENSION_3_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_3_DIM_BYTES.: &[u8] = &[
400 0, 0, 0, 3, 64, 0, 0, 0, 0, 0, 0, 0, 64, 8, 0, 0, 0, 0, 0, 0, 64, 16, 0, 0, 0, 0, 0, 0, 64,
401 20, 0, 0, 0, 0, 0, 0, 64, 24, 0, 0, 0, 0, 0, 0, 64, 28, 0, 0, 0, 0, 0, 0,
402 ];
403
404 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
405 fn can_deserialise_point_type_byesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_point_type_byes().() {
406 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(POINT_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/POINT_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
407 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(2.))
408 }
409
410 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
411 fn can_deserialise_point_type_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_point_type_str().() {
412 let cube_1 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(2)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
413 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_1, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(2.));
414 let cube_2 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
415 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_2, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(2.));
416 }
417
418 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
419 fn can_serialise_point_typerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_serialise_point_type().() {
420 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::Pointrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#Point#(2.).serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(), POINT_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/POINT_BYTES.,)
421 }
422 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
423 fn can_deserialise_zero_volume_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_zero_volume_bytes().() {
424 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(ZERO_VOLUME_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ZERO_VOLUME_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
425 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3.]));
426 }
427
428 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
429 fn can_deserialise_zero_volume_stringrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_zero_volume_string().() {
430 let cube_1 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(2,3,4)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
431 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_1, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.]));
432 let cube_2 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("2,3,4").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
433 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_2, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.]));
434 }
435
436 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
437 fn can_serialise_zero_volumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_serialise_zero_volume().() {
438 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
439 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::ZeroVolumerust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#ZeroVolume#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3.]).serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(),
440 ZERO_VOLUME_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ZERO_VOLUME_BYTES.
441 );
442 }
443
444 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
445 fn can_deserialise_one_dimension_interval_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_one_dimension_interval_bytes().() {
446 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(ONE_DIMENSIONAL_INTERVAL_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ONE_DIMENSIONAL_INTERVAL_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
447 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(7., 8.))
448 }
449
450 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
451 fn can_deserialise_one_dimension_interval_stringrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_one_dimension_interval_string().() {
452 let cube_1 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("((7),(8))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
453 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_1, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(7., 8.));
454 let cube_2 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(7),(8)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
455 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cube_2, PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(7., 8.));
456 }
457
458 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
459 fn can_serialise_one_dimension_intervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_serialise_one_dimension_interval().() {
460 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
461 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::OneDimensionIntervalrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#OneDimensionInterval#(7., 8.).serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(),
462 ONE_DIMENSIONAL_INTERVAL_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/ONE_DIMENSIONAL_INTERVAL_BYTES.
463 )
464 }
465
466 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
467 fn can_deserialise_multi_dimension_2_dimension_byterust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_multi_dimension_2_dimension_byte().() {
468 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(MULTI_DIMENSION_2_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_2_DIM_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
470 cube,
471 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]])
472 )
473 }
474
475 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
476 fn can_deserialise_multi_dimension_2_dimension_stringrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_multi_dimension_2_dimension_string().() {
477 let cube_1 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("((1,2),(3,4))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
478 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
479 cube_1,
480 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]])
481 );
482 let cube_2 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("((1, 2), (3, 4))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
483 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
484 cube_2,
485 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]])
486 );
487 let cube_3 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(1,2),(3,4)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
488 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
489 cube_3,
490 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]])
491 );
492 let cube_4 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(1, 2), (3, 4)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
493 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
494 cube_4,
495 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]])
496 )
497 }
498
499 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
500 fn can_serialise_multi_dimension_2_dimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_serialise_multi_dimension_2_dimension().() {
501 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
502 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![1., 2.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![3., 4.]]).serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(),
503 MULTI_DIMENSION_2_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_2_DIM_BYTES.
504 )
505 }
506
507 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
508 fn can_deserialise_multi_dimension_3_dimension_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_multi_dimension_3_dimension_bytes().() {
509 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]from_bytes().(MULTI_DIMENSION_3_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_3_DIM_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
510 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
511 cube,
512 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![5., 6., 7.]])
513 )
514 }
515
516 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
517 fn can_deserialise_multi_dimension_3_dimension_stringrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_deserialise_multi_dimension_3_dimension_string().() {
518 let cube = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("((2,3,4),(5,6,7))").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
519 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
520 cube,
521 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![5., 6., 7.]])
522 );
523 let cube_2 = PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube][FromStr]from_str().("(2,3,4),(5,6,7)").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
524 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
525 cube_2,
526 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![5., 6., 7.]])
527 );
528 }
529
530 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
531 fn can_serialise_multi_dimension_3_dimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/can_serialise_multi_dimension_3_dimension().() {
532 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
533 PgCuberust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#::MultiDimensionrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/PgCube#MultiDimension#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![2., 3., 4.], vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![5., 6., 7.]]).serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/impl#[PgCube]serialize_to_vec().(),
534 MULTI_DIMENSION_3_DIM_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/cube/cube_tests/MULTI_DIMENSION_3_DIM_BYTES.
535 )
536 }
537 }