Skip to content

Commit

Permalink
add dummy query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDC committed Apr 1, 2024
1 parent 44e5c4a commit 61a2732
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,16 @@ fn impl_from_args_struct(
None => format_ident!("{}DB", name),
};

let name_query_builder = format_ident!("{}QueryBuilder", name_db);

let db_doc = format!(
"An in-memory database for storing instances of [`{}`], generated by `#[derive(VennDB)]`.",
name
);
let query_doc = format!(
"A query builder for querying instances of [`{}`] in a [`{}`] database.",
name, name_db
);
quote! {
#[doc=#db_doc]
#vis struct #name_db {
Expand All @@ -101,12 +107,22 @@ fn impl_from_args_struct(
#vis fn is_empty(&self) -> bool {
self.rows.is_empty()
}

/// Query the database using a query builder.
#vis fn query(&self) -> #name_query_builder {
#name_query_builder { db: self }
}
}

impl Default for #name_db {
fn default() -> Self {
Self::new()
}
}

#[doc=#query_doc]
#vis struct #name_query_builder<'a> {
db: &'a #name_db,
}
}
}

0 comments on commit 61a2732

Please sign in to comment.