This commit is contained in:
2025-04-22 08:24:17 +04:00
parent d75de1e73c
commit cad285fd59
13 changed files with 659 additions and 129 deletions

View File

@@ -1,47 +1,12 @@
//! # Hero Models
//!
//! A library for hero models with base model trait implementation.
//!
//! This crate provides a base model trait and implementation that other models can inherit from.
//! It also provides a Comment model that can be used to add comments to any model.
// Export core module
pub mod core;
pub mod model;
pub mod comment;
pub mod user;
// Export userexample module
pub mod userexample;
// Re-export key types for convenience
pub use model::{BaseModel, BaseModelData, IndexKey, impl_base_model};
pub use comment::Comment;
pub use user::User;
pub use core::{BaseModel, BaseModelData, IndexKey, ModelBuilder};
pub use core::Comment;
pub use userexample::User;
/// Example of how to use the heromodels crate
///
/// ```rust
/// use heromodels::{BaseModel, User, Comment};
///
/// // Create a new user
/// let mut user = User::new(
/// 1,
/// "johndoe".to_string(),
/// "john.doe@example.com".to_string(),
/// "John Doe".to_string()
/// );
///
/// // Create a comment for the user
/// let comment = Comment::new(
/// 1,
/// 2, // commenter's user ID
/// user.get_id(),
/// User::db_prefix().to_string(),
/// "This is a comment on the user".to_string()
/// );
///
/// // Add the comment to the user
/// user.base_data.add_comment(comment.get_id());
///
/// // Get the database prefix for the User model
/// assert_eq!(User::db_prefix(), "user");
///
/// // Get the database keys for the user
/// let keys = user.db_keys();
/// assert!(keys.iter().any(|k| k.name == "username" && k.value == "johndoe"));
// No need to re-export macros as they are already exported at the crate root