Skip to main content

oxilean_kernel/ffi/
ffitype_traits.rs

1//! # FfiType - Trait Implementations
2//!
3//! This module contains trait implementations for `FfiType`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::types::FfiType;
12use std::fmt;
13
14impl fmt::Display for FfiType {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        match self {
17            FfiType::Bool => write!(f, "bool"),
18            FfiType::UInt8 => write!(f, "u8"),
19            FfiType::UInt16 => write!(f, "u16"),
20            FfiType::UInt32 => write!(f, "u32"),
21            FfiType::UInt64 => write!(f, "u64"),
22            FfiType::Int8 => write!(f, "i8"),
23            FfiType::Int16 => write!(f, "i16"),
24            FfiType::Int32 => write!(f, "i32"),
25            FfiType::Int64 => write!(f, "i64"),
26            FfiType::Float32 => write!(f, "f32"),
27            FfiType::Float64 => write!(f, "f64"),
28            FfiType::String => write!(f, "string"),
29            FfiType::ByteArray => write!(f, "bytes"),
30            FfiType::Unit => write!(f, "()"),
31            FfiType::Ptr(inner) => write!(f, "*{}", inner),
32            FfiType::Fn(params, ret) => {
33                write!(f, "fn(")?;
34                for (i, param) in params.iter().enumerate() {
35                    if i > 0 {
36                        write!(f, ", ")?;
37                    }
38                    write!(f, "{}", param)?;
39                }
40                write!(f, ") -> {}", ret)
41            }
42            FfiType::OxiLean(name) => write!(f, "OxiLean({})", name),
43        }
44    }
45}