worktable_macros 0.9.0

Proc-macro companion crate for worktable: the worktable! macro and its derives. Formerly published as worktable_codegen.
Documentation
use proc_macro2::{Ident, Span};
use syn::ItemStruct;

use crate::common::name_generator::WorktableNameGenerator;

pub use space_file::WT_INDEX_EXTENSION;

mod space;
mod space_file;

pub struct PersistTableAttributes {
    pub pk_unsized: bool,
    pub read_only: bool,
}

pub struct Generator {
    pub struct_def: ItemStruct,
    pub pk_ident: Ident,
    pub attributes: PersistTableAttributes,
}

impl WorktableNameGenerator {
    pub fn get_space_file_ident(&self) -> Ident {
        Ident::new(format!("{}SpaceFile", self.name).as_str(), Span::mixed_site())
    }

    pub fn get_persistence_engine_ident(&self) -> Ident {
        Ident::new(format!("{}PersistenceEngine", self.name).as_str(), Span::mixed_site())
    }

    pub fn get_persistence_task_ident(&self) -> Ident {
        Ident::new(format!("{}PersistenceTask", self.name).as_str(), Span::mixed_site())
    }
}