mod scalars;
mod containers;
pub mod table;
mod operators;
pub use scalars::*;
pub use containers::*;
pub use table::*;
pub use operators::*;
use crate::error::{RayforceError, Result};
use crate::ffi::RayObj;
use crate::*;
pub trait RayType: Sized {
const TYPE_CODE: i8;
const RAY_NAME: &'static str;
fn from_ptr(ptr: RayObj) -> Result<Self>;
fn ptr(&self) -> &RayObj;
fn type_code(&self) -> i8 {
self.ptr().type_code()
}
}
pub fn to_ray<T: Into<RayObj>>(value: T) -> RayObj {
value.into()
}
pub fn from_ray<T: TryFrom<RayObj, Error = RayforceError>>(obj: RayObj) -> Result<T> {
T::try_from(obj)
}
pub fn type_name_for_code(code: i8) -> &'static str {
match code.abs() as u32 {
TYPE_LIST => "RayList",
TYPE_B8 => "RayBool",
TYPE_U8 => "RayU8",
TYPE_I16 => "RayI16",
TYPE_I32 => "RayI32",
TYPE_I64 => "RayI64",
TYPE_SYMBOL => "RaySymbol",
TYPE_DATE => "RayDate",
TYPE_TIME => "RayTime",
TYPE_TIMESTAMP => "RayTimestamp",
TYPE_F64 => "RayF64",
TYPE_GUID => "RayGuid",
TYPE_C8 => "RayString",
TYPE_ENUM => "RayEnum",
TYPE_TABLE => "RayTable",
TYPE_DICT => "RayDict",
TYPE_LAMBDA => "RayLambda",
TYPE_UNARY => "RayUnary",
TYPE_BINARY => "RayBinary",
TYPE_VARY => "RayVariadic",
TYPE_NULL => "RayNull",
TYPE_ERR => "RayError",
_ => "Unknown",
}
}