Skip to main content

Citizen

Trait Citizen 

Source
pub trait Citizen:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn citizen_symbol() -> Symbol;
    fn citizen_version() -> u32;
    fn citizen_arity() -> usize;
    fn citizen_fields() -> &'static [&'static str];
}
Expand description

Static citizen identity: the metadata #[derive(Citizen)] supplies.

Reports the citizen’s class symbol, encoding version, constructor arity, and field names. The kernel owns Symbol; this trait is the Rust-side identity a citizen registers against the kernel’s class and read-construct contracts.

§Examples

#[derive(Citizen)] supplies this identity from the #[citizen(...)] attribute and the struct’s fields:

#[derive(Clone, Debug, Default, PartialEq, Citizen)]
#[citizen(symbol = "doc/Point", version = 1)]
struct Point {
    x: i64,
    y: i64,
}

assert_eq!(Point::citizen_symbol().to_string(), "doc/Point");
assert_eq!(Point::citizen_version(), 1);
assert_eq!(Point::citizen_arity(), 2);
assert_eq!(Point::citizen_fields(), &["x", "y"]);

Required Methods§

Source

fn citizen_symbol() -> Symbol

The citizen’s namespace/name class symbol.

Source

fn citizen_version() -> u32

The citizen’s encoding version.

Source

fn citizen_arity() -> usize

Number of constructor fields (excluding the version argument).

Source

fn citizen_fields() -> &'static [&'static str]

The citizen’s field names, in constructor order.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§