it: track whether objects have been deleted
This commit is contained in:
parent
cdab4d4cad
commit
6af9d909b8
22 changed files with 167 additions and 45 deletions
|
|
@ -4,7 +4,7 @@ use {
|
|||
object::{Interface, ObjectId},
|
||||
utils::buffd::MsgParser,
|
||||
},
|
||||
std::rc::Rc,
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
||||
macro_rules! test_object {
|
||||
|
|
@ -14,6 +14,10 @@ macro_rules! test_object {
|
|||
self.id.into()
|
||||
}
|
||||
|
||||
fn deleted(&self) -> &Deleted {
|
||||
&self.deleted
|
||||
}
|
||||
|
||||
#[allow(unused_variables, unreachable_code)]
|
||||
fn handle_request(
|
||||
self: std::rc::Rc<Self>,
|
||||
|
|
@ -37,8 +41,25 @@ macro_rules! test_object {
|
|||
};
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Deleted(Cell<bool>);
|
||||
|
||||
impl Deleted {
|
||||
pub fn set(&self) {
|
||||
self.0.set(true);
|
||||
}
|
||||
|
||||
pub fn check(&self) -> Result<(), TestError> {
|
||||
match self.0.get() {
|
||||
true => bail!("Object has already been deleted"),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TestObjectBase: 'static {
|
||||
fn id(&self) -> ObjectId;
|
||||
fn deleted(&self) -> &Deleted;
|
||||
fn handle_request(
|
||||
self: Rc<Self>,
|
||||
request: u32,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue