-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
Description
I needed the ability the cache multiple Symbols in a struct across FFI calls.
I didn't want to use a self referental struct, so instead I created a OwnedSymbol type that keeps
the library alive as long as needed.
pub struct OwnedSymbol<T> {
inner: imp::Symbol<T>,
library: Arc<Library>,
}
// Obtain a OwnedSymbol
impl Library {
pub unsafe fn get_owned<T>(self: Arc<Self>, symbol: &[u8]) -> Result<OwnedSymbol<T>, Error> {
self.0
.get(symbol)
.map(|from| OwnedSymbol::from_raw(from, self))
}
}Is that something you'd like to see upstream? I've seen a few issues/pr's that reference something similar.
If so, I would document the new type and functions, write the tests and get a pull request going.
notpeelz