use thiserror::Error;
pub const SYSTEM_SYMBOL_TABLE: &[&str; 10] = &[
"$0",
"$ion",
"$ion_1_0",
"$ion_symbol_table",
"name",
"version",
"imports",
"symbols",
"max_id",
"$ion_shared_symbol_table",
];
#[allow(dead_code)]
#[derive(Eq, PartialEq, Debug, Clone, Copy)]
pub(crate) enum SystemSymbolIds {
Zero = 0x00,
Ion = 0x01,
Ion10 = 0x02,
IonSymbolTable = 0x03,
Name = 0x04,
Version = 0x05,
Imports = 0x06,
Symbols = 0x07,
MaxId = 0x08,
IonSharedSymbolTable = 0x09,
}
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum ValueLength {
ShortLength(u8), LongLength, NullValue, }
#[derive(Eq, PartialEq, Debug)]
pub enum ValueType {
Null, Nop, Bool, PositiveInt, NegativeInt, Float, Decimal, Timestamp, Symbol, String, Clob, Blob, List, SExpr, Struct, Annotation, Reserved, }
#[derive(Eq, PartialEq, Debug, Error)]
pub enum ParsingError {
#[error("Header type not valid")]
InvalidHeaderType,
#[error("Header length not valid")]
InvalidHeaderLength,
#[error("Reached end of the ion stream")]
NoDataToRead,
#[error("There is not enough data to read, provably a premature ion stream end")]
NotEnoughtDataToRead(usize),
#[error("The read method returned an error which mean that the ion stream provider may have a problem")]
ErrorReadingData(String),
#[error("Trying to read 0 bytes")]
CannotReadZeroBytes,
#[error("Ion Stream Header is wrong")]
BadFormedVersionHeader,
#[error("Null cannot have len")]
InvalidNullLength(ValueLength),
#[error("Annotation cannot be shorter than 3 bytes")]
InvalidAnnotationLength(ValueLength),
#[error("VaruInt returned a number so huge that doesn't fit in an BitUInt")]
ThisIsABugConsumingVarUInt,
#[error("VaruInt returned a number so huge that doesn't fit in an BitInt")]
ThisIsABugConsumingVarInt,
}
#[derive(Eq, PartialEq, Debug)]
pub struct ValueHeader {
pub r#type: ValueType, pub length: ValueLength, }