SemanticVersion struct.
Additional documentation.
This commit is contained in:
parent
58b68e0aef
commit
72a24ad023
@ -66,5 +66,6 @@ pub mod trie;
|
|||||||
pub mod nibbleslice;
|
pub mod nibbleslice;
|
||||||
pub mod heapsizeof;
|
pub mod heapsizeof;
|
||||||
pub mod squeeze;
|
pub mod squeeze;
|
||||||
|
pub mod semantic_version;
|
||||||
|
|
||||||
//pub mod network;
|
//pub mod network;
|
||||||
|
28
src/semantic_version.rs
Normal file
28
src/semantic_version.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/// A version value with strict meaning. Use `to_u32` to convert to a simple integer.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// extern crate ethcore;
|
||||||
|
/// use ethcore::engine::*;
|
||||||
|
/// fn main() {
|
||||||
|
/// assert_eq!(SemanticVersion::new(1, 2, 3).as_u32(), 0x010203);
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
pub struct SemanticVersion {
|
||||||
|
/// Major version - API/feature removals & breaking changes.
|
||||||
|
pub major: u8,
|
||||||
|
/// Minor version - API/feature additions.
|
||||||
|
pub minor: u8,
|
||||||
|
/// Tiny version - bug fixes.
|
||||||
|
pub tiny: u8,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SemanticVersion {
|
||||||
|
/// Create a new object.
|
||||||
|
pub fn new(major: u8, minor: u8, tiny: u8) -> SemanticVersion { SemanticVersion{major: major, minor: minor, tiny: tiny} }
|
||||||
|
|
||||||
|
/// Convert to a `u32` representation.
|
||||||
|
pub fn as_u32(&self) -> u32 { ((self.major as u32) << 16) + ((self.minor as u32) << 8) + self.tiny as u32 }
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: implement Eq, Comparison and Debug/Display for SemanticVersion.
|
@ -11,8 +11,11 @@ enum Operation {
|
|||||||
Delete(H256),
|
Delete(H256),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// How many insertions and removals were done in an `apply` operation.
|
||||||
pub struct Score {
|
pub struct Score {
|
||||||
|
/// Number of insertions.
|
||||||
pub inserts: usize,
|
pub inserts: usize,
|
||||||
|
/// Number of removals.
|
||||||
pub removes: usize,
|
pub removes: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +57,7 @@ impl Journal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Apply this journal to the HashDB `db` and return the number of insertions and removals done.
|
||||||
pub fn apply(self, db: &mut HashDB) -> Score {
|
pub fn apply(self, db: &mut HashDB) -> Score {
|
||||||
trace!("applying {:?} changes", self.0.len());
|
trace!("applying {:?} changes", self.0.len());
|
||||||
let mut ret = Score{inserts: 0, removes: 0};
|
let mut ret = Score{inserts: 0, removes: 0};
|
||||||
|
Loading…
Reference in New Issue
Block a user