Skip to content

Commit 0b0b269

Browse files
marked decimal128.rs as not implemented yet. waiting for rust-lang/rfcs#3453 to be available in stable rust.
1 parent 93aab46 commit 0b0b269

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

amqp-type/src/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ pub enum AppError {
88
DeserializationIllegalConstructorError(u8),
99
#[error("Iterator was empty or too short.")]
1010
IteratorEmptyOrTooShortError,
11-
#[error("Error while converting Decimal128.")]
12-
Decimal128ConversionError(#[from] crate::fixed_width::decimal128::Decimal128ConversionError),
1311
}
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
use bigdecimal::BigDecimal;
2+
use crate::error::AppError;
3+
use crate::serde::decode::Decode;
24

35
use crate::serde::encode::{Encode, Encoded};
46

57
#[derive(Hash, Eq, PartialEq)]
68
pub struct Decimal128(BigDecimal);
79

10+
11+
/**
12+
f128 implemented in
13+
https://github.com/rust-lang/rfcs/pull/3453
14+
implement this when it is available in stable.
15+
*/
816
impl Encode for Decimal128 {
917
fn encode(&self) -> Encoded {
1018
0x94.into()
1119
}
1220
}
1321

14-
impl From<f64> for Decimal128 {
15-
fn from(value: f64) -> Self {
16-
Decimal128(BigDecimal::try_from(value).unwrap())
22+
impl Decode for Decimal128 {
23+
fn can_decode(_iter: impl Iterator<Item=u8>) -> bool {
24+
false // Not implemented yet
1725
}
18-
}
1926

20-
#[derive(thiserror::Error, Debug)]
21-
pub enum Decimal128ConversionError {
22-
#[error("Coefficient is too large for Decimal128 representation.")]
23-
CoefficientTooLarge,
24-
#[error("Exponent overflowed in Decimal128 representation")]
25-
ExponentOverflow,
26-
#[error("Exponent underflowed in Decimal128 representation")]
27-
ExponentUnderflow,
27+
fn try_decode(_iter: impl Iterator<Item=u8>) -> Result<Self, AppError> where Self: Sized {
28+
todo!("Decimal128 type is not implemented yet")
29+
}
2830
}
2931

3032
#[cfg(test)]
3133
mod test {
32-
use super::*;
33-
34-
#[test]
35-
fn construct_decimal_128() {
36-
let val: Decimal128 = 128.0.into();
37-
assert_eq!(val.encode().constructor(), 0x94);
38-
}
3934
}

0 commit comments

Comments
 (0)