Mercurial > hg
comparison rust/hg-core/src/revlog/revlog.rs @ 46390:0800aa42bb4c
rust: use the bytes-cast crate to parse persistent nodemaps
This crate casts pointers to custom structs, with compile-time safety checks,
for easy and efficient binary data parsing.
See https://crates.io/crates/bytes-cast and
https://docs.rs/bytes-cast/0.1.0/bytes_cast/
Differential Revision: https://phab.mercurial-scm.org/D9788
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 15 Jan 2021 16:11:54 +0100 |
parents | 8a4914397d02 |
children | 645ee7225fab |
comparison
equal
deleted
inserted
replaced
46389:38b9a63d3a13 | 46390:0800aa42bb4c |
---|---|
25 InvalidRevision, | 25 InvalidRevision, |
26 /// Found more than one entry whose ID match the requested prefix | 26 /// Found more than one entry whose ID match the requested prefix |
27 AmbiguousPrefix, | 27 AmbiguousPrefix, |
28 Corrupted, | 28 Corrupted, |
29 UnknowDataFormat(u8), | 29 UnknowDataFormat(u8), |
30 } | |
31 | |
32 impl From<bytes_cast::FromBytesError> for RevlogError { | |
33 fn from(_: bytes_cast::FromBytesError) -> Self { | |
34 RevlogError::Corrupted | |
35 } | |
30 } | 36 } |
31 | 37 |
32 /// Read only implementation of revlog. | 38 /// Read only implementation of revlog. |
33 pub struct Revlog { | 39 pub struct Revlog { |
34 /// When index and data are not interleaved: bytes of the revlog index. | 40 /// When index and data are not interleaved: bytes of the revlog index. |