[][src]Macro agnes::tablespace

macro_rules! tablespace {
    (@fields() -> ($($out:tt)*)) => { ... };
    (@fields(,) -> ($($out:tt)*)) => { ... };
    (@fields
        (,$field_name:ident: $field_ty:ident = {$str_name:expr} $($rest:tt)*)
        ->
        ($($out:tt)*)
    ) => { ... };
    (@fields
        (,$field_name:ident: $field_ty:ident $($rest:tt)*)
        ->
        ($($out:tt)*)
    ) => { ... };
    (@body($($body:tt)*)) => { ... };
    (@construct($vis:vis $tbl_name:ident)($nat:ty)($($body:tt)*)) => { ... };
    (@continue($prev_tbl:ty)) => { ... };
    (@continue($prev_tbl:ty)
        $vis:vis table $tbl_name:ident {
            $($body:tt)*
        }
        $($rest:tt)*
    ) => { ... };
    (
        $vis:vis table $tbl_name:ident {
            $($body:tt)*
        }
        $($rest:tt)*
    ) => { ... };
}

Declares a set of data tables that all occupy the same tablespace (i.e. can be merged or joined together). This macro should be used at the beginning of any agnes-using code, to declare the various source and constructed table field labels.

Calls to this macro should include one or more table declarations, which have similar syntax to struct definitions: a comma-separated list of name: type pairs for each member of the table. Like a struct declaration, a table declaration can be preceded by a visibility modifier (e.g. pub).

This macro will declare a module for each table specified (with the appropriate visibility) and constructs label marker structs for each field specified within the table.

Example

The following macro call declares two tables: employee and department. The employee table has three fields (two u64 fields and one String field), and the department table has two fields (one u64 field and one String field).

tablespace![
    pub table employee {
        EmpId: u64,
        DeptId: u64,
        EmpName: String,
    }
    table department {
        DeptId: u64,
        DeptName: String,
    }
];

As a result of calling this macro, two modules will be declared --namespace and department -- as well as the specified field labels within those modules. In this case, the employee table will have public visibility, while the department table will be private. After declaring these modules, you can refer to the labels as you would a normal type; e.g., employee::EmpId.