brokkr-models::models::stacks Rust
Structs
brokkr-models::models::stacks::Stack
pub
Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``
Represents a stack in the database.
Fields
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the stack. |
created_at | DateTime < Utc > | Timestamp when the stack was created. |
updated_at | DateTime < Utc > | Timestamp when the stack was last updated. |
deleted_at | Option < DateTime < Utc > > | Timestamp for soft deletion, if applicable. |
name | String | Name of the stack. |
description | Option < String > | Optional description of the stack. |
generator_id | Uuid | Optional generator ID. |
brokkr-models::models::stacks::NewStack
pub
Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema
Represents a new stack to be inserted into the database.
Fields
| Name | Type | Description |
|---|---|---|
name | String | Name of the stack. |
description | Option < String > | Optional description of the stack. |
generator_id | Uuid | Optional generator ID. |
Methods
new pub
#![allow(unused)]
fn main() {
fn new (name : String , description : Option < String > , generator_id : Uuid ,) -> Result < Self , String >
}
Creates a new NewStack instance.
Parameters:
| Name | Type | Description |
|---|---|---|
name | - | Name of the stack. Must be a non-empty string. |
description | - | Optional description of the stack. If provided, must not be an empty string. |
generator_id | - | Optional generator ID. |
Returns:
Returns Ok(NewStack) 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>,
generator_id: Uuid,
) -> Result<Self, String> {
// Validate name
if name.trim().is_empty() {
return Err("Stack name cannot be empty".to_string());
}
// Validate description (if provided)
if let Some(desc) = &description {
if desc.trim().is_empty() {
return Err("Stack description cannot be empty if provided".to_string());
}
}
Ok(NewStack {
name,
description,
generator_id,
})
}
}