napi-rs/examples/napi/src/class_factory.rs
2021-11-25 23:42:40 +08:00

18 lines
279 B
Rust

#[napi]
pub struct ClassWithFactory {
pub name: String,
}
#[napi]
impl ClassWithFactory {
#[napi(factory)]
pub fn with_name(name: String) -> Self {
Self { name }
}
#[napi]
pub fn set_name(&mut self, name: String) -> &Self {
self.name = name;
self
}
}