HsType

Enum HsType 

Source
#[non_exhaustive]
pub enum HsType {
Show 19 variants CInt, CChar, CSChar, CUChar, CShort, CUShort, CUInt, CLong, CULong, CLLong, CULLong, CBool, CString, CDouble, CFloat, Empty, Ptr(Box<HsType>), IO(Box<HsType>), FunPtr(Vec<HsType>),
}
Expand description

Enumeration of all Haskell C-FFI safe types as the string representation of their token in Haskell.

FIXME: Errno(c_int) should be implemented as a Rust enum … https://hackage.haskell.org/package/base/docs/Foreign-C-Error.html … using #[repr(i32)] https://doc.rust-lang.org/nomicon/other-reprs.html

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

CInt

Int32

§

CChar

Int8

§

CSChar

Int8

§

CUChar

Word8

§

CShort

Int16

§

CUShort

Word16

§

CUInt

Word32

§

CLong

Int64

§

CULong

Word64

§

CLLong

Int64

§

CULLong

Word64

§

CBool

Word8

§

CString

Ptr CChar

§

CDouble

Double

§

CFloat

Float

§

Empty

()

§

Ptr(Box<HsType>)

Ptr T

§

IO(Box<HsType>)

IO T

§

FunPtr(Vec<HsType>)

FunPtr (S -> T)

Implementations§

Source§

impl HsType

Source

pub fn quote(&self) -> TokenStream

Get the C-FFI Rust type that match the memory layout of a given HsType.

This function return a OUTPUT: proc_macro2::TokenStream that should be valid (considered as FFI-safe by rustc) in the context of a block of form: quote! { extern C fn _(_: #OUTPUT) {} }

c.f. https://doc.rust-lang.org/core/ffi/

Trait Implementations§

Source§

impl Display for HsType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for HsType

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

§

impl Freeze for HsType

§

impl RefUnwindSafe for HsType

§

impl Send for HsType

§

impl Sync for HsType

§

impl Unpin for HsType

§

impl UnwindSafe for HsType

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.