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