stratisd icon indicating copy to clipboard operation
stratisd copied to clipboard

Destroy and teardown should somehow mark layers of the stack as torn down on success

Open jbaublitz opened this issue 4 years ago • 3 comments

@mulkieran While working on #2355, I noticed that a lot of our destroy methods take &mut self. Would it make more sense here to use self and let Rust's ownership checking guarantee that the entity can't be used after it's destroyed? I need to at least change this for the crypt layer as I've tried to make the code simpler by guaranteeing that if you have a CryptHandle, the device is active. However, I'm wondering if this would add a benefit across our code base.

jbaublitz avatar Jan 06 '21 14:01 jbaublitz

I think this is now obsolete.

jbaublitz avatar Feb 28 '23 22:02 jbaublitz

Reopening this because of #3274 and #3285

jbaublitz avatar Mar 17 '23 20:03 jbaublitz

I think taking self is actually a bad idea just because of the fallible nature of the teardown methods. I'd almost rather still take &mut self but create a new data type to mark a layer as deactivated so that it can't be accessed afterwards. I think this is a larger and longer term redesign so I'm going to put this to the side for now.

jbaublitz avatar Mar 23 '23 16:03 jbaublitz