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

Structs

brokkr-models::models::agents::Agent

pub

Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents an agent in the database.

Fields

NameTypeDescription
idUuidUnique identifier for the agent.
created_atDateTime < Utc >Timestamp when the agent was created.
updated_atDateTime < Utc >Timestamp when the agent was last updated.
deleted_atOption < DateTime < Utc > >Timestamp for soft deletion, if applicable.
nameStringName of the agent.
cluster_nameStringName of the cluster the agent belongs to.
last_heartbeatOption < DateTime < Utc > >Timestamp of the last heartbeat received from the agent.
statusStringCurrent status of the agent.
pak_hashStringHash of the agent’s Pre-shared Authentication Key (PAK).

brokkr-models::models::agents::NewAgent

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema

Represents a new agent to be inserted into the database.

Fields

NameTypeDescription
nameStringName of the agent.
cluster_nameStringName of the cluster the agent belongs to.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (name : String , cluster_name : String) -> Result < Self , String >
}

Creates a new NewAgent instance.

Parameters:

NameTypeDescription
name-Name of the agent. Must be a non-empty string.
cluster_name-Name of the cluster the agent belongs to. Must be a non-empty string.

Returns:

Returns Ok(NewAgent) if both parameters are valid non-empty strings, otherwise returns an Err with a description of the validation failure.

Source
#![allow(unused)]
fn main() {
    pub fn new(name: String, cluster_name: String) -> Result<Self, String> {
        // Validate name
        if name.trim().is_empty() {
            return Err("Agent name cannot be empty".to_string());
        }

        // Validate cluster_name
        if cluster_name.trim().is_empty() {
            return Err("Cluster name cannot be empty".to_string());
        }

        Ok(NewAgent { name, cluster_name })
    }
}