/rust/registry/src/index.crates.io-1949cf8c6b5b557f/surrealmx-0.22.0/src/version.rs
Line | Count | Source |
1 | | // Copyright © SurrealDB Ltd |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | //! This module stores a MVCC versioned entry. |
16 | | |
17 | | use bytes::Bytes; |
18 | | use std::cmp::Ordering; |
19 | | |
20 | | #[derive(Clone, Eq, PartialEq)] |
21 | | pub struct Version { |
22 | | /// The version of this entry |
23 | | pub(crate) version: u64, |
24 | | /// The value of this entry. If this is |
25 | | /// None, then the key is deleted and if |
26 | | /// it is Some then the key exists. |
27 | | pub(crate) value: Option<Bytes>, |
28 | | } |
29 | | |
30 | | impl Ord for Version { |
31 | | #[inline] |
32 | 0 | fn cmp(&self, other: &Self) -> Ordering { |
33 | 0 | self.version.cmp(&other.version) |
34 | 0 | } |
35 | | } |
36 | | |
37 | | impl PartialOrd for Version { |
38 | | #[inline] |
39 | 0 | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
40 | 0 | Some(self.cmp(other)) |
41 | 0 | } |
42 | | } |