Skip to content

Commit a599546

Browse files
committed
better explain use of input.name
1 parent fa0f1d6 commit a599546

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

nexus/src/db/db-macros/src/lookup.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ use quote::{format_ident, quote};
1717
// NOTE: this is only "pub" for the `cargo doc` link on [`lookup_resource!`].
1818
#[derive(serde::Deserialize)]
1919
pub struct Input {
20-
/// Name of the resource (PascalCase)
20+
/// Name of the resource
21+
///
22+
/// This is taken as the name of the database model type in
23+
/// `omicron_nexus::db::model`, the name of the authz type in
24+
/// `omicron_nexus::authz`, and will be the name of the new type created by
25+
/// this macro. The snake case version of the name is taken as the name of
26+
/// the Diesel table interface in `db::schema`.
27+
///
28+
/// This value is typically PascalCase (e.g., "Organization").
2129
name: String,
2230
/// ordered list of resources that are ancestors of this resource, starting
2331
/// with the top of the hierarchy
@@ -77,8 +85,8 @@ pub struct Config {
7785
path_authz_names: Vec<syn::Ident>,
7886

7987
// Child resources
80-
/// list of names of child resources (PascalCase, raw input to the macro)
81-
/// (e.g., [`Instance`, `Disk`])
88+
/// list of names of child resources, in the same form and with the same
89+
/// assumptions as [`Input::name`] (i.e., typically PascalCase)
8290
child_resources: Vec<String>,
8391

8492
// Parent resource, if any
@@ -118,6 +126,8 @@ impl Config {
118126
/// ancestor in its path)
119127
struct Resource {
120128
/// PascalCase resource name itself (e.g., `Project`)
129+
///
130+
/// See [`Input::name`] for more on the assumptions and how it's used.
121131
name: syn::Ident,
122132
/// snake_case resource name (e.g., `project`)
123133
name_as_snake: String,

0 commit comments

Comments
 (0)