inferadb-derive 0.1.0

Derive macros for InferaDB SDK
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 9.54 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 307.51 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • inferadb/rust
    2 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • evansims

Derive macros for the InferaDB SDK.

This crate provides derive macros for implementing the Resource and Subject traits, enabling type-safe authorization operations.

Usage

Add to your Cargo.toml:

[dependencies]
inferadb = { version = "0.1", features = ["derive"] }

Examples

use inferadb::derive::{Resource, Subject};

#[derive(Resource)]
#[resource(type = "document")]
struct Document {
    #[resource(id)]
    id: String,
    title: String,
}

#[derive(Subject)]
#[subject(type = "user")]
struct User {
    #[subject(id)]
    id: String,
    name: String,
}

// Now you can use these with the InferaDB SDK
let doc = Document { id: "readme".into(), title: "README".into() };
let user = User { id: "alice".into(), name: "Alice".into() };

// Type-safe API
assert_eq!(doc.as_resource_ref(), "document:readme");
assert_eq!(user.as_subject_ref(), "user:alice");