Skip to content

Commit bf3c702

Browse files
stefano-poglianizonyitoo
authored andcommitted
bson timestamps are LE (#98)
1 parent 4a19ba6 commit bf3c702

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/decoder/serde.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,12 @@ impl<'de> Deserialize<'de> for TimeStamp {
592592

593593
match Bson::deserialize(deserializer)? {
594594
Bson::TimeStamp(ts) => {
595-
let ts = ts.to_be();
595+
let ts = ts.to_le();
596596

597597
Ok(TimeStamp { t: ((ts as u64) >> 32) as u32,
598598
i: (ts & 0xFFFF_FFFF) as u32, })
599599
}
600-
_ => Err(D::Error::custom("expecting UtcDateTime")),
600+
_ => Err(D::Error::custom("expecting TimeStamp")),
601601
}
602602
}
603603
}

tests/serde.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn test_de_timestamp() {
6969
}
7070

7171
let foo: Foo = bson::from_bson(Bson::Document(doc! {
72-
"ts": Bson::TimeStamp(0x0A00_0000_0C00_0000),
72+
"ts": Bson::TimeStamp(0x0000_000C_0000_000A),
7373
})).unwrap();
7474

7575
assert_eq!(foo.ts, TimeStamp { t: 12, i: 10 });

0 commit comments

Comments
 (0)