vc-runtime 0.1.0

Runtime backend for Visual Compiler
Documentation
//! ComfyUI-specific deterministic validation.

use super::super::{BackendValidationError, ConfigError};
use crate::config::model::ComfyConfig;

/// Validates a single ComfyUI backend configuration.
pub fn validate_backend(backend_name: &str, cfg: &ComfyConfig) -> Result<(), ConfigError> {
    if cfg.timeout_secs == 0 {
        return Err(BackendValidationError::ZeroTimeout { backend: backend_name.to_owned() }.into());
    }
    if cfg.poll_timeout_secs == 0 {
        return Err(
            BackendValidationError::ZeroPollTimeout { backend: backend_name.to_owned() }.into()
        );
    }
    if cfg.poll_interval_ms == 0 {
        return Err(
            BackendValidationError::ZeroPollInterval { backend: backend_name.to_owned() }.into()
        );
    }
    if !matches!(cfg.base_url.scheme(), "http" | "https") {
        return Err(BackendValidationError::UnsupportedScheme {
            backend: backend_name.to_owned(),
            scheme: cfg.base_url.scheme().to_owned(),
        }
        .into());
    }
    Ok(())
}