2 unstable releases
0.2.0 | Jan 29, 2023 |
---|---|
0.1.0 | May 3, 2021 |
#41 in #java-class
Used in jaded
37KB
790 lines
Jaded-derive
Derive macro for the jaded Java deserialization library to support the 'derive' feature. Code should not have to depend on this crate directly, but should use jaded instead.
lib.rs
:
Derive macro for automatically implementing jaded::FromJava
for Rust types.
This is provided as a FromJava
macro.
Most implementations of FromJava
will be very similar and automatically deriving them makes
much more sense than writing almost identical impl blocks for every type.
For a 'simple' bean style Java class, eg
public class Person implements Serializable {
private String firstName;
private String familyName;
private int age;
}
The rust equivalent can be automatically derived
#[derive(FromJava)]
struct Person {
firstName: String,
familyName: String,
age: i32,
}
To allow both Java and rust to keep to their respective naming conventions, a 'rename' feature is available that allows camelCase java fields to be read into snake_case rust fields
#[derive(FromJava)]
#[jaded(rename)]
struct Person {
first_name: String,
family_name: String,
age: i32,
}
Dependencies
~1.5MB
~37K SLoC