brokkr-models::models::generator Rust
Structs
brokkr-models::models::generator::Generator
pub
Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``
Represents a generator in the Brokkr system.
Fields
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the generator. |
created_at | DateTime < Utc > | Timestamp of when the generator was created. |
updated_at | DateTime < Utc > | Timestamp of when the generator was last updated. |
deleted_at | Option < DateTime < Utc > > | Timestamp of when the generator was deleted, if applicable. |
name | String | Name of the generator. |
description | Option < String > | Optional description of the generator. |
pak_hash | Option < String > | Hash of the Pre-Authentication Key (PAK) for the generator. |
last_active_at | Option < DateTime < Utc > > | Timestamp of when the generator was last active. |
is_active | bool | Indicates whether the generator is currently active. |
brokkr-models::models::generator::NewGenerator
pub
Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema
Represents the data required to create a new generator.
Fields
| Name | Type | Description |
|---|---|---|
name | String | Name of the new generator. |
description | Option < String > | Optional description of the new generator. |
Methods
new pub
#![allow(unused)]
fn main() {
fn new (name : String , description : Option < String >) -> Result < Self , String >
}
Creates a new NewGenerator instance.
Parameters:
| Name | Type | Description |
|---|---|---|
name | - | The name for the generator. Must be non-empty and not exceed 255 characters. |
description | - | An optional description for the generator. |
Returns:
Returns Ok(NewGenerator) if all parameters are valid, otherwise returns an Err with a description of the validation failure.
Source
#![allow(unused)]
fn main() {
pub fn new(name: String, description: Option<String>) -> Result<Self, String> {
if name.trim().is_empty() {
return Err("Generator name cannot be empty".to_string());
}
if name.len() > 255 {
return Err("Generator name cannot exceed 255 characters".to_string());
}
Ok(NewGenerator { name, description })
}
}