Description
I recently came across this library and so far it has been working well for the needs of our open-source project. Thank you! 🙏
In particular, the clone feature proposed in #112 (we test-drove @SLUCHABLUB's branch) got us ~90% to a working solution. The remaining ~10% we are missing is what this feature request is about.
We are looking for a way to supply and apply additional custom attributes to the generated impl
blocks.
Consider the following example:
use getset::Getters;
#[derive(Getters)]
#[getset(get)]
pub struct PodJob {
pub name: String,
}
// generates
//
// impl PodJob {
// #[inline(always)]
// fn name(&self) -> &String {
// &self.name
// }
// }
Now we'd like to expose this PodJob
struct and these getter methods over a CFFI boundary. This is actually pretty straightforward with a nifty project called UniFFI. To do this, here's how we export the methods without getset
(clone used since that is a better real-world example).
use uniffi;
#[derive(uniffi::Object)]
pub struct PodJob {
pub name: String,
}
#[uniffi::export]
impl PodJob {
fn name(&self) -> String {
self.name.clone()
}
}
If there was a feature that could easily allow us to automate adding custom attributes then this package could be even more applicable in reducing the needed boilerplate for such cases. Perhaps the configuration and result could look like the following:
use uniffi;
use getset::CloneGetters;
#[derive(uniffi::Object, CloneGetters)]
#[getset(get_clone, impl_attrs = "#[uniffi::export]")]
pub struct PodJob {
pub name: String,
}
// generates
//
// #[uniffi::export]
// impl PodJob {
// #[inline(always)]
// fn name(&self) -> String {
// self.name.clone()
// }
// }