qualia_core_db/net/peer/runtime/
handles.rs1use crate::net::qdnf::errors::QdnfError;
4use crate::net::qdnf::types::Generation;
5
6#[repr(C)]
7#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
8pub struct LeaseHandle {
9 pub slot: u16,
10 pub generation: Generation,
11}
12
13impl LeaseHandle {
14 pub const INVALID: Self = Self {
15 slot: 0,
16 generation: Generation::ZERO,
17 };
18
19 pub fn matches(self, expected: Self) -> Result<(), QdnfError> {
21 if self.slot != expected.slot || self.generation != expected.generation {
22 Err(QdnfError::StaleGeneration)
23 } else {
24 Ok(())
25 }
26 }
27}
28
29#[repr(C)]
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31pub struct BufferLease {
32 pub handle: LeaseHandle,
33 pub capacity: u32,
34 pub initialized: u32,
35 pub exclusive: bool,
36}