rust/hg-core/src/revlog/node.rs
changeset 46744 b1f2c2b336ec
parent 46595 98a455a62699
child 48421 2097f63575a5
equal deleted inserted replaced
46743:84a3deca963a 46744:b1f2c2b336ec
    28 
    28 
    29 /// The length in bytes of a `Node`
    29 /// The length in bytes of a `Node`
    30 ///
    30 ///
    31 /// see also `NODES_BYTES_LENGTH` about it being private.
    31 /// see also `NODES_BYTES_LENGTH` about it being private.
    32 const NODE_NYBBLES_LENGTH: usize = 2 * NODE_BYTES_LENGTH;
    32 const NODE_NYBBLES_LENGTH: usize = 2 * NODE_BYTES_LENGTH;
       
    33 
       
    34 /// Default for UI presentation
       
    35 const SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH: u8 = 12;
    33 
    36 
    34 /// Private alias for readability and to ease future change
    37 /// Private alias for readability and to ease future change
    35 type NodeData = [u8; NODE_BYTES_LENGTH];
    38 type NodeData = [u8; NODE_BYTES_LENGTH];
    36 
    39 
    37 /// Binary revision SHA
    40 /// Binary revision SHA
   161     ///
   164     ///
   162     /// This is needed by FFI layers, for instance to return expected
   165     /// This is needed by FFI layers, for instance to return expected
   163     /// binary values to Python.
   166     /// binary values to Python.
   164     pub fn as_bytes(&self) -> &[u8] {
   167     pub fn as_bytes(&self) -> &[u8] {
   165         &self.data
   168         &self.data
       
   169     }
       
   170 
       
   171     pub fn short(&self) -> NodePrefix {
       
   172         NodePrefix {
       
   173             nybbles_len: SHORT_PREFIX_DEFAULT_NYBBLES_LENGTH,
       
   174             data: self.data,
       
   175         }
   166     }
   176     }
   167 }
   177 }
   168 
   178 
   169 /// The beginning of a binary revision SHA.
   179 /// The beginning of a binary revision SHA.
   170 ///
   180 ///