fp_bindgen/types/
custom_type.rs

1use super::{CargoDependency, TypeIdent};
2use std::{collections::BTreeMap, hash::Hash};
3
4/// Used for defining type information for types that are defined externally,
5/// or that otherwise require custom treatment.
6#[derive(Clone, Debug, Eq, Hash, PartialEq)]
7pub struct CustomType {
8    pub ident: TypeIdent,
9
10    /// Qualified path to refer to the type in the Rust generators.
11    pub rs_ty: String,
12
13    /// Dependencies to add to the Rust plugin's `Cargo.toml` to be able to
14    /// use the type.
15    ///
16    /// Keys in the map are dependency names as they appear on the left-hand
17    /// side of the `=` in the `Cargo.toml` `[dependencies]` section, while the
18    /// value describes what comes on the right-hand side.
19    pub rs_dependencies: BTreeMap<&'static str, CargoDependency>,
20
21    /// Serde attributes to add to fields of this type.
22    pub serde_attrs: Vec<String>,
23
24    /// Name to refer to the type in the TypeScript generator.
25    pub ts_ty: String,
26
27    /// Optional declaration, for when `ts_ty` does not refer to a built-in
28    /// type.
29    pub ts_declaration: Option<String>,
30}