Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

NameTypeDescription
idUuidUnique identifier for the stack.
created_atDateTime < Utc >Timestamp when the stack was created.
updated_atDateTime < Utc >Timestamp when the stack was last updated.
deleted_atOption < DateTime < Utc > >Timestamp for soft deletion, if applicable.
nameStringName of the stack.
descriptionOption < String >Optional description of the stack.
generator_idUuidOptional 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

NameTypeDescription
nameStringName of the stack.
descriptionOption < String >Optional description of the stack.
generator_idUuidOptional 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:

NameTypeDescription
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,
        })
    }
}