#![deny(rustdoc::missing_crate_level_docs)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![doc = include_str!("../Readme.md")]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/11549616")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/11549616")]
use num::BigInt;
use ordered_float::OrderedFloat;
use std::collections::BTreeMap;
mod associations;
mod error;
mod extensions;
mod functions;
mod numbers;
mod packed_array;
mod traits;
mod utils;
pub use crate::{
associations::{WolframPair, WolframRule},
error::{Result, WolframError},
extensions::*,
functions::{WolframFunction, WolframSymbol},
packed_array::WolframArray,
traits::{object_builder::WolframSerializer, readable_writer::ReadableWriter},
utils::*,
};
pub trait ToWolfram {
fn to_wolfram(&self) -> WolframValue;
fn to_wolfram_string(&self) -> String {
self.to_wolfram().to_string()
}
fn to_wolfram_bytes(&self) -> Vec<u8> {
self.to_wolfram().to_bytes()
}
fn to_wolfram_solid(&self) -> Vec<u8> {
self.to_wolfram().to_compressed()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
pub enum WolframValue {
Skip,
Function(Box<WolframFunction>),
Boolean(bool),
String(String),
Bytes(Vec<u8>),
Symbol(Box<WolframSymbol>),
Integer8(i8),
Integer16(i16),
Integer32(i32),
Integer64(i64),
BigInteger(BigInt),
Decimal64(OrderedFloat<f64>),
BigDecimal(String),
PackedArray(WolframArray),
NumericArray(WolframArray),
Association(BTreeMap<WolframValue, (WolframRule, WolframValue)>),
}
impl Default for WolframValue {
fn default() -> Self {
Self::Skip
}
}