it: simplify tracking of deleted objects
This commit is contained in:
parent
ae34a65efe
commit
fd027d9a5a
17 changed files with 57 additions and 154 deletions
|
|
@ -4,7 +4,7 @@ use {
|
|||
object::{Interface, ObjectId},
|
||||
utils::buffd::MsgParser,
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
macro_rules! test_object {
|
||||
|
|
@ -14,10 +14,6 @@ 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>,
|
||||
|
|
@ -41,25 +37,8 @@ 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