Skip to main content

synapse_codegen_cfs/
types.rs

1use std::collections::HashMap;
2
3/// Deterministic banner included at the top of generated files.
4pub const GENERATED_BANNER: &str = "Generated by Synapse. Do not edit directly.";
5
6/// Preamble included at the top of generated cFS C headers.
7pub const PREAMBLE: &str = "\
8/* Generated by Synapse. Do not edit directly. */
9#pragma once
10#include \"cfe.h\"
11
12";
13
14/// Resolved integer constants visible to a file from imported namespaces.
15pub type ResolvedConstants = HashMap<Vec<String>, u64>;
16
17/// cFS packet category used by mission-wide validation.
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub enum CfsPacketKind {
20    /// cFS Software Bus command packet.
21    Command,
22    /// cFS Software Bus telemetry packet.
23    Telemetry,
24}
25
26/// Resolved cFS packet facts for registry-style validation.
27#[derive(Debug, Clone, PartialEq, Eq)]
28pub struct CfsPacket {
29    /// Namespace segments declared by the source file, if any.
30    pub namespace: Vec<String>,
31    /// Packet declaration name.
32    pub name: String,
33    /// Packet kind.
34    pub kind: CfsPacketKind,
35    /// Resolved numeric message ID.
36    pub mid: u64,
37    /// Resolved numeric command code for command packets.
38    pub cc: Option<u64>,
39}
40
41/// Options for Rust cFS binding generation.
42pub struct RustOptions<'a> {
43    /// Module path prefix for the cFS header types.
44    /// e.g. `"cfs"` -> `cfs::TelemetryHeader`, `"cfe_sys"` -> `cfe_sys::TelemetryHeader`.
45    /// Set to `""` to use bare type names.
46    pub cfs_module: &'a str,
47    /// Rust type name for telemetry message headers. Default: `"TelemetryHeader"`.
48    pub tlm_header: &'a str,
49    /// Rust type name for command message headers. Default: `"CommandHeader"`.
50    pub cmd_header: &'a str,
51}
52
53impl Default for RustOptions<'_> {
54    fn default() -> Self {
55        RustOptions {
56            cfs_module: "cfs_sys",
57            tlm_header: "CFE_MSG_TelemetryHeader_t",
58            cmd_header: "CFE_MSG_CommandHeader_t",
59        }
60    }
61}