cfs-synapse-codegen-cfs 0.2.10

cFS C and Rust code generator for Synapse IDL files
Documentation
use std::collections::HashMap;

/// Deterministic banner included at the top of generated files.
pub const GENERATED_BANNER: &str = "Generated by Synapse. Do not edit directly.";

/// Preamble included at the top of generated cFS C headers.
pub const PREAMBLE: &str = "\
/* Generated by Synapse. Do not edit directly. */
#pragma once
#include \"cfe.h\"

";

/// Resolved integer constants visible to a file from imported namespaces.
pub type ResolvedConstants = HashMap<Vec<String>, u64>;

/// cFS packet category used by mission-wide validation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CfsPacketKind {
    /// cFS Software Bus command packet.
    Command,
    /// cFS Software Bus telemetry packet.
    Telemetry,
}

/// Resolved cFS packet facts for registry-style validation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CfsPacket {
    /// Namespace segments declared by the source file, if any.
    pub namespace: Vec<String>,
    /// Packet declaration name.
    pub name: String,
    /// Packet kind.
    pub kind: CfsPacketKind,
    /// Resolved numeric message ID.
    pub mid: u64,
    /// Resolved numeric command code for command packets.
    pub cc: Option<u64>,
}

/// Options for Rust cFS binding generation.
pub struct RustOptions<'a> {
    /// Module path prefix for the cFS header types.
    /// e.g. `"cfs"` -> `cfs::TelemetryHeader`, `"cfe_sys"` -> `cfe_sys::TelemetryHeader`.
    /// Set to `""` to use bare type names.
    pub cfs_module: &'a str,
    /// Rust type name for telemetry message headers. Default: `"TelemetryHeader"`.
    pub tlm_header: &'a str,
    /// Rust type name for command message headers. Default: `"CommandHeader"`.
    pub cmd_header: &'a str,
}

impl Default for RustOptions<'_> {
    fn default() -> Self {
        RustOptions {
            cfs_module: "cfs_sys",
            tlm_header: "CFE_MSG_TelemetryHeader_t",
            cmd_header: "CFE_MSG_CommandHeader_t",
        }
    }
}