Implement Integral Data Types (#13)

**Rationale:**

Integral Types were missing and are needed for Project Nautilus.

**Changes:**

- Implements Integral Data Types
  - u64 and i64 implemented through bigint

Reviewed-on: #13
Co-authored-by: Sergey Savelyev <sergeysav.nn@gmail.com>
Co-committed-by: Sergey Savelyev <sergeysav.nn@gmail.com>
This commit was merged in pull request #13.
This commit is contained in:
2026-01-03 08:37:26 -08:00
committed by sergeysav
parent 458c94c2ad
commit 167e9d0a01
21 changed files with 343 additions and 56 deletions

View File

@@ -45,3 +45,16 @@ pub trait IntoCommandDefinition: Sized {
fn parse(command: Command) -> Result<Self, IntoCommandDefinitionError>;
}
impl IntoCommandDefinition for () {
fn create(name: String) -> CommandDefinition {
CommandDefinition {
name,
parameters: vec![],
}
}
fn parse(_: Command) -> Result<Self, IntoCommandDefinitionError> {
Ok(())
}
}

View File

@@ -7,6 +7,32 @@ pub enum DataType {
Float32,
Float64,
Boolean,
Int8,
Int16,
Int32,
Int64,
Unsigned8,
Unsigned16,
Unsigned32,
Unsigned64,
}
impl DataType {
pub fn get_data_length(self) -> u64 {
match self {
DataType::Float32 => 4,
DataType::Float64 => 8,
DataType::Boolean => 1,
DataType::Int8 => 1,
DataType::Int16 => 2,
DataType::Int32 => 4,
DataType::Int64 => 8,
DataType::Unsigned8 => 1,
DataType::Unsigned16 => 2,
DataType::Unsigned32 => 4,
DataType::Unsigned64 => 8,
}
}
}
pub trait ToDataType: Into<DataValue> {
@@ -24,3 +50,11 @@ macro_rules! impl_to_data_type {
impl_to_data_type!(f32, DataType::Float32);
impl_to_data_type!(f64, DataType::Float64);
impl_to_data_type!(bool, DataType::Boolean);
impl_to_data_type!(i8, DataType::Int8);
impl_to_data_type!(i16, DataType::Int16);
impl_to_data_type!(i32, DataType::Int32);
impl_to_data_type!(i64, DataType::Int64);
impl_to_data_type!(u8, DataType::Unsigned8);
impl_to_data_type!(u16, DataType::Unsigned16);
impl_to_data_type!(u32, DataType::Unsigned32);
impl_to_data_type!(u64, DataType::Unsigned64);

View File

@@ -7,6 +7,14 @@ pub enum DataValue {
Float32(f32),
Float64(f64),
Boolean(bool),
Int8(i8),
Int16(i16),
Int32(i32),
Int64(i64),
Unsigned8(u8),
Unsigned16(u16),
Unsigned32(u32),
Unsigned64(u64),
}
impl DataValue {
@@ -15,6 +23,14 @@ impl DataValue {
DataValue::Float32(_) => DataType::Float32,
DataValue::Float64(_) => DataType::Float64,
DataValue::Boolean(_) => DataType::Boolean,
DataValue::Int8(_) => DataType::Int8,
DataValue::Int16(_) => DataType::Int16,
DataValue::Int32(_) => DataType::Int32,
DataValue::Int64(_) => DataType::Int64,
DataValue::Unsigned8(_) => DataType::Unsigned8,
DataValue::Unsigned16(_) => DataType::Unsigned16,
DataValue::Unsigned32(_) => DataType::Unsigned32,
DataValue::Unsigned64(_) => DataType::Unsigned64,
}
}
}