Skip to main content

oxilean_codegen/ffi_bridge/
ffidecl_traits.rs

1//! # FfiDecl - Trait Implementations
2//!
3//! This module contains trait implementations for `FfiDecl`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::lcnf::*;
12
13use super::types::FfiDecl;
14use std::fmt;
15
16impl fmt::Display for FfiDecl {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        write!(f, "@[extern {}] ", self.extern_name)?;
19        if self.is_unsafe {
20            write!(f, "unsafe ")?;
21        }
22        write!(f, "fn {}(", self.name)?;
23        for (i, (pname, pty)) in self.params.iter().enumerate() {
24            if i > 0 {
25                write!(f, ", ")?;
26            }
27            write!(f, "{}: {}", pname, pty)?;
28        }
29        write!(f, ") -> {} [{}]", self.ret_type, self.calling_conv)
30    }
31}