1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// Copyright (c) 2019 RepliXio Ltd. All rights reserved.
// Use is subject to license terms.
//

use serde::{Deserialize, Serialize};
use std::fmt;

#[repr(C)]
#[derive(Copy, Clone, Serialize, Deserialize)]
pub struct pmemoid {
    pool_uuid_lo: u64,
    off: u64,
}

impl Default for pmemoid {
    #[inline(always)]
    fn default() -> Self {
        Self {
            pool_uuid_lo: 0,
            off: 0,
        }
    }
}

impl fmt::Debug for pmemoid {
    #[inline(always)]
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "pmemoid pool: {}, off: {:x}",
            self.pool_uuid_lo, self.off
        )
    }
}

impl pmemoid {
    pub fn new(pool_uuid_lo: u64, off: u64) -> Self {
        Self { pool_uuid_lo, off }
    }

    pub fn off(&self) -> u64 {
        self.off
    }

    pub fn pool_uuid_lo(&self) -> u64 {
        self.pool_uuid_lo
    }
}

pub type PMEMoid = pmemoid;