comparison rust/hg-core/src/revlog/nodemap.rs @ 46428:5893706af3de

rust: Simplify error type for reading hex node IDs If a string is not valid hexadecimal it’s not that useful to track the precise reason. Differential Revision: https://phab.mercurial-scm.org/D9861
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 25 Jan 2021 12:28:39 +0100
parents 0800aa42bb4c
children 645ee7225fab
comparison
equal deleted inserted replaced
46427:6380efb82191 46428:5893706af3de
11 //! 11 //!
12 //! Following existing implicit conventions, the "nodemap" terminology 12 //! Following existing implicit conventions, the "nodemap" terminology
13 //! is used in a more abstract context. 13 //! is used in a more abstract context.
14 14
15 use super::{ 15 use super::{
16 node::NULL_NODE, Node, NodeError, NodePrefix, NodePrefixRef, Revision, 16 node::NULL_NODE, FromHexError, Node, NodePrefix, NodePrefixRef, Revision,
17 RevlogIndex, NULL_REVISION, 17 RevlogIndex, NULL_REVISION,
18 }; 18 };
19 19
20 use bytes_cast::{unaligned, BytesCast}; 20 use bytes_cast::{unaligned, BytesCast};
21 use std::cmp::max; 21 use std::cmp::max;
25 use std::ops::Index; 25 use std::ops::Index;
26 26
27 #[derive(Debug, PartialEq)] 27 #[derive(Debug, PartialEq)]
28 pub enum NodeMapError { 28 pub enum NodeMapError {
29 MultipleResults, 29 MultipleResults,
30 InvalidNodePrefix(NodeError), 30 InvalidNodePrefix,
31 /// A `Revision` stored in the nodemap could not be found in the index 31 /// A `Revision` stored in the nodemap could not be found in the index
32 RevisionNotInIndex(Revision), 32 RevisionNotInIndex(Revision),
33 } 33 }
34 34
35 impl From<NodeError> for NodeMapError { 35 impl From<FromHexError> for NodeMapError {
36 fn from(err: NodeError) -> Self { 36 fn from(_: FromHexError) -> Self {
37 NodeMapError::InvalidNodePrefix(err) 37 NodeMapError::InvalidNodePrefix
38 } 38 }
39 } 39 }
40 40
41 /// Mapping system from Mercurial nodes to revision numbers. 41 /// Mapping system from Mercurial nodes to revision numbers.
42 /// 42 ///