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::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

NameTypeDescription
idUuidUnique identifier for the generator.
created_atDateTime < Utc >Timestamp of when the generator was created.
updated_atDateTime < Utc >Timestamp of when the generator was last updated.
deleted_atOption < DateTime < Utc > >Timestamp of when the generator was deleted, if applicable.
nameStringName of the generator.
descriptionOption < String >Optional description of the generator.
pak_hashOption < String >Hash of the Pre-Authentication Key (PAK) for the generator.
last_active_atOption < DateTime < Utc > >Timestamp of when the generator was last active.
is_activeboolIndicates 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

NameTypeDescription
nameStringName of the new generator.
descriptionOption < 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:

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