Comments (3)
How about trying #[napi(object)]
look at here, https://napi.rs/docs/concepts/object, #[napi]
means class
while #[napi(object)]
means object
#![deny(clippy::all)]
#[macro_use]
extern crate napi_derive;
#[derive(Clone)]
#[napi(object)] // change here
pub struct Element {
pub name: String,
}
#[napi] // you can keep it if it's a class
pub struct Parent {
pub elements: Vec<Element>,
}
I copied the above code directly into my project, and it compiled correctly (the content outside the screenshot is my original project, don't worry about it)
If your original intention is that Element is a class, then this seems to be a mistake (I'm not sure).
I tried the following code but it failed to compile and I encountered the same error.
#[derive(Clone)]
#[napi(constructor)] // change here
pub struct Element {
pub name: String,
}
#[napi]
pub struct Parent {
pub elements: Vec<Element>,
}
from napi-rs.
+1 - I've run into this too!
from napi-rs.
Running into this as well:
/// The result of the operation.
///
/// A function returning this type indicates that
/// it will attempt to continue through errors,
/// collecting them and returning them alongside
/// any successful results.
///
/// Such functions _should_ only result in an exception
/// due to extreme runtime issues, for example
/// if the process runs out of memory and times out
/// trying to allocate more.
#[derive(Clone, Eq, PartialEq, Debug)]
#[napi(object)]
pub struct Resilient<T, E> {
pub ok: Option<T>,
pub errors: Vec<E>,
}
Output snippet from cargo build
:
error[E0107]: missing generics for struct `Resilient`
--> src/lib.rs:151:12
|
151 | pub struct Resilient<T, E> {
| ^^^^^^^^^ expected 2 generic arguments
|
note: struct defined here, with 2 generic parameters: `T`, `E`
--> src/lib.rs:151:12
|
151 | pub struct Resilient<T, E> {
| ^^^^^^^^^ - -
help: add missing generic arguments
|
151 | pub struct Resilient<T, E><T, E> {
| ++++++
from napi-rs.
Related Issues (20)
- Unexpect `Nul` Error of CString while creating javascript object HOT 1
- #[napi(constructor)] | ^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument HOT 1
- napi build doesn't respect alternative target paths
- I get an error when writing callbacks with napi-rs HOT 1
- CI failed due to yarn's version
- Is there a way auto transform struct field which is i128 to BigInt? HOT 4
- public Ser and De? HOT 3
- Provide "Env" to ThreadSafeFunction.call_with_return_value() HOT 1
- Error: "linking with `cc` " when using napi bindings from external crate from "cargo test" HOT 2
- Difference in Strings with null chars in Behavior in compat mode and normal mode.
- AbortSignal can't be re-used by `AsyncTask::with_optional_signal` HOT 1
- Unable to use custom error status in factory/constructor
- TLS Communication Error in Rust Node.js Addon Built with napi-cli
- Unable to set custom rustc flags due to napi cli setting `RUSTFLAGS` when building for musl
- RFC: "async_local" feature for local-thread concurrency HOT 3
- pass object/class as parameter HOT 3
- Errors in thread safe functions cause fatal panic HOT 1
- Customized error status? HOT 2
- Export `processTypeDef` from js package
- some suggestions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from napi-rs.