| 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 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#; |
| 8 | |
| 9 | const ERRORrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/ERROR.: &str = "error decoding LINE"; |
| 10 | |
| 11 | /// ## Postgres Geometric Line type |
| 12 | /// |
| 13 | /// Description: Infinite line |
| 14 | /// Representation: `{A, B, C}` |
| 15 | /// |
| 16 | /// Lines are represented by the linear equation Ax + By + C = 0, where A and B are not both zero. |
| 17 | /// |
| 18 | /// See https://www.postgresql.org/docs/16/datatype-geometric.html#DATATYPE-LINE |
| 19 | #[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:)] |
| 20 | pub struct PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 21 | pub arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a.: f64, |
| 22 | pub brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b.: f64, |
| 23 | pub crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c.: f64, |
| 24 | } |
| 25 | |
| 26 | impl Typerust-analyzer cargo sqlx-core 0.8.3 types/Type#<Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 27 | fn type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][`Type<Postgres>`]type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 28 | 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().("line") |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | impl PgHasArrayTyperust-analyzer cargo sqlx-postgres 0.8.3 types/array/PgHasArrayType# for PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 33 | fn array_type_inforust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][PgHasArrayType]array_type_info().() -> PgTypeInforust-analyzer cargo sqlx-postgres 0.8.3 type_info/PgTypeInfo# { |
| 34 | 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().("_line") |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | impl<'r> Decoderust-analyzer cargo sqlx-core 0.8.3 decode/Decode#<'r, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 39 | fn decoderust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][`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/geometry/line/impl#[PgLine][`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#>> { |
| 40 | match value.formatrust-analyzer cargo sqlx-postgres 0.8.3 value/impl#[`PgValueRef<'r>`]format().() { |
| 41 | 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#(PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][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().), |
| 42 | 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#(PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]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().), |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | impl<'q> Encoderust-analyzer cargo sqlx-core 0.8.3 encode/Encode#<'q, Postgresrust-analyzer cargo sqlx-postgres 0.8.3 database/Postgres#> for PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 48 | fn producesrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][`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#> { |
| 49 | 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().("line")) |
| 50 | } |
| 51 | |
| 52 | fn encode_by_refrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][`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#> { |
| 53 | self.serializerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]serialize().(buf)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 54 | 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#) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 59 | type Errrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]Err# = BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#; |
| 60 | |
| 61 | fn from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][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/geometry/line/impl#[PgLine][FromStr], Selfrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 62 | let mut parts = s |
| 63 | .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().'}' || 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().' ') |
| 64 | .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(','); |
| 65 | |
| 66 | let a = parts |
| 67 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 68 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<f64>().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 69 | .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!!("{}: could not get a from {}", ERRORrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/ERROR., s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 70 | |
| 71 | let b = parts |
| 72 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 73 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<f64>().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 74 | .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!!("{}: could not get b from {}", ERRORrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/ERROR., s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 75 | |
| 76 | let c = parts |
| 77 | .nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() |
| 78 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|s| s.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<f64>().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()) |
| 79 | .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!!("{}: could not get c from {}", ERRORrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/ERROR., s))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 80 | |
| 81 | if parts.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 82 | 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!!("{}: too many numbers inputted in {}", ERRORrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/ERROR., s).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 83 | } |
| 84 | |
| 85 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a., brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b., crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c. }) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | impl PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 90 | fn from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]from_bytes().(mut bytes: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#, BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 91 | let a = bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().(); |
| 92 | let b = bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().(); |
| 93 | let c = bytes.get_f64rust-analyzer cargo bytes 1.12.1 buf/buf_impl/Buf#get_f64().(); |
| 94 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a., brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b., crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c. }) |
| 95 | } |
| 96 | |
| 97 | fn serializerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]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#<(), BoxDynErrorrust-analyzer cargo sqlx-core 0.8.3 error/BoxDynError#> { |
| 98 | buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&self.arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a..to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().()); |
| 99 | buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&self.brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b..to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().()); |
| 100 | buff.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(&self.crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c..to_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]to_be_bytes().()); |
| 101 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 102 | } |
| 103 | |
| 104 | #[cfg(test)] |
| 105 | fn serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]serialize_to_vec().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 106 | 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().(); |
| 107 | self.serializerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]serialize().(&mut buff).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 108 | buff.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().() |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | #[cfg(test)] |
| 113 | mod line_testsrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/ { |
| 114 | |
| 115 | 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#; |
| 116 | |
| 117 | use superrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/::PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#; |
| 118 | |
| 119 | const LINE_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/LINE_BYTES.: &[u8] = &[ |
| 120 | 63, 241, 153, 153, 153, 153, 153, 154, 64, 1, 153, 153, 153, 153, 153, 154, 64, 10, 102, |
| 121 | 102, 102, 102, 102, 102, |
| 122 | ]; |
| 123 | |
| 124 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 125 | fn can_deserialise_line_type_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/can_deserialise_line_type_bytes().() { |
| 126 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_bytesrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]from_bytes().(LINE_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/LINE_BYTES.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 127 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 128 | line, |
| 129 | PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 130 | arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a.: 1.1, |
| 131 | brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b.: 2.2, |
| 132 | crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c.: 3.3 |
| 133 | } |
| 134 | ) |
| 135 | } |
| 136 | |
| 137 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 138 | fn can_deserialise_line_type_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/can_deserialise_line_type_str().() { |
| 139 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]from_str().("{ 1, 2, 3 }").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 140 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 141 | line, |
| 142 | PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 143 | arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a.: 1.0, |
| 144 | brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b.: 2.0, |
| 145 | crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c.: 3.0 |
| 146 | } |
| 147 | ); |
| 148 | } |
| 149 | |
| 150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 151 | fn cannot_deserialise_line_too_few_numbersrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/cannot_deserialise_line_too_few_numbers().() { |
| 152 | let input_str = "{ 1, 2 }"; |
| 153 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]from_str().(input_str); |
| 154 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(line.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 155 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) = line { |
| 156 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 157 | err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 158 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("error decoding LINE: could not get c from {input_str}") |
| 159 | ) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 164 | fn cannot_deserialise_line_too_many_numbersrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/cannot_deserialise_line_too_many_numbers().() { |
| 165 | let input_str = "{ 1, 2, 3, 4 }"; |
| 166 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]from_str().(input_str); |
| 167 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(line.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 168 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) = line { |
| 169 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 170 | err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 171 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("error decoding LINE: too many numbers inputted in {input_str}") |
| 172 | ) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 177 | fn cannot_deserialise_line_invalid_numbersrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/cannot_deserialise_line_invalid_numbers().() { |
| 178 | let input_str = "{ 1, 2, three }"; |
| 179 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]from_str().(input_str); |
| 180 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(line.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 181 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) = line { |
| 182 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 183 | err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 184 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("error decoding LINE: could not get c from {input_str}") |
| 185 | ) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 190 | fn can_deserialise_line_type_str_floatrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/can_deserialise_line_type_str_float().() { |
| 191 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#::from_strrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine][FromStr]from_str().("{1.1, 2.2, 3.3}").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 192 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 193 | line, |
| 194 | PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 195 | arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a.: 1.1, |
| 196 | brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b.: 2.2, |
| 197 | crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c.: 3.3 |
| 198 | } |
| 199 | ); |
| 200 | } |
| 201 | |
| 202 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 203 | fn can_serialise_line_typerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/can_serialise_line_type().() { |
| 204 | let line = PgLinerust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine# { |
| 205 | arust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#a.: 1.1, |
| 206 | brust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#b.: 2.2, |
| 207 | crust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/PgLine#c.: 3.3, |
| 208 | }; |
| 209 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(line.serialize_to_vecrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/impl#[PgLine]serialize_to_vec().(), LINE_BYTESrust-analyzer cargo sqlx-postgres 0.8.3 types/geometry/line/line_tests/LINE_BYTES.,) |
| 210 | } |
| 211 | } |