omnisci 0.1.0

A client for connecting to OmniSciDB using the Thrift API.
Documentation
// Generated from OmniSciDB commit efe1d864d6804d67e796fa4213219a2df2e49901
// Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

#![allow(unused_imports)]
#![allow(unused_extern_crates)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments, clippy::type_complexity))]
#![cfg_attr(rustfmt, rustfmt_skip)]

extern crate thrift;

use thrift::OrderedFloat;
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::{From, TryFrom};
use std::default::Default;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::rc::Rc;

use thrift::{ApplicationError, ApplicationErrorKind, ProtocolError, ProtocolErrorKind, TThriftClient};
use thrift::protocol::{TFieldIdentifier, TListIdentifier, TMapIdentifier, TMessageIdentifier, TMessageType, TInputProtocol, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType};
use thrift::protocol::field_id;
use thrift::protocol::verify_expected_message_type;
use thrift::protocol::verify_expected_sequence_number;
use thrift::protocol::verify_expected_service_call;
use thrift::protocol::verify_required_field_exists;
use thrift::server::TProcessor;

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TDeviceType {
  Cpu = 0,
  Gpu = 1,
}

impl TDeviceType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TDeviceType> {
    let enum_value = i_prot.read_i32()?;
    TDeviceType::try_from(enum_value)  }
}

impl TryFrom<i32> for TDeviceType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TDeviceType::Cpu),
      1 => Ok(TDeviceType::Gpu),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TDeviceType", i)
            )
          )
        )
      },
    }
  }
}

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TDatumType {
  Smallint = 0,
  Int = 1,
  Bigint = 2,
  Float = 3,
  Decimal = 4,
  Double = 5,
  Str = 6,
  Time = 7,
  Timestamp = 8,
  Date = 9,
  Bool = 10,
  IntervalDayTime = 11,
  IntervalYearMonth = 12,
  Point = 13,
  Linestring = 14,
  Polygon = 15,
  Multipolygon = 16,
  Tinyint = 17,
  Geometry = 18,
  Geography = 19,
}

impl TDatumType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TDatumType> {
    let enum_value = i_prot.read_i32()?;
    TDatumType::try_from(enum_value)  }
}

impl TryFrom<i32> for TDatumType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TDatumType::Smallint),
      1 => Ok(TDatumType::Int),
      2 => Ok(TDatumType::Bigint),
      3 => Ok(TDatumType::Float),
      4 => Ok(TDatumType::Decimal),
      5 => Ok(TDatumType::Double),
      6 => Ok(TDatumType::Str),
      7 => Ok(TDatumType::Time),
      8 => Ok(TDatumType::Timestamp),
      9 => Ok(TDatumType::Date),
      10 => Ok(TDatumType::Bool),
      11 => Ok(TDatumType::IntervalDayTime),
      12 => Ok(TDatumType::IntervalYearMonth),
      13 => Ok(TDatumType::Point),
      14 => Ok(TDatumType::Linestring),
      15 => Ok(TDatumType::Polygon),
      16 => Ok(TDatumType::Multipolygon),
      17 => Ok(TDatumType::Tinyint),
      18 => Ok(TDatumType::Geometry),
      19 => Ok(TDatumType::Geography),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TDatumType", i)
            )
          )
        )
      },
    }
  }
}

#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum TEncodingType {
  None = 0,
  Fixed = 1,
  Rl = 2,
  Diff = 3,
  Dict = 4,
  Sparse = 5,
  Geoint = 6,
  DateInDays = 7,
}

impl TEncodingType {
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    o_prot.write_i32(*self as i32)
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TEncodingType> {
    let enum_value = i_prot.read_i32()?;
    TEncodingType::try_from(enum_value)  }
}

impl TryFrom<i32> for TEncodingType {
  type Error = thrift::Error;  fn try_from(i: i32) -> Result<Self, Self::Error> {
    match i {
      0 => Ok(TEncodingType::None),
      1 => Ok(TEncodingType::Fixed),
      2 => Ok(TEncodingType::Rl),
      3 => Ok(TEncodingType::Diff),
      4 => Ok(TEncodingType::Dict),
      5 => Ok(TEncodingType::Sparse),
      6 => Ok(TEncodingType::Geoint),
      7 => Ok(TEncodingType::DateInDays),
      _ => {
        Err(
          thrift::Error::Protocol(
            ProtocolError::new(
              ProtocolErrorKind::InvalidData,
              format!("cannot convert enum constant {} to TEncodingType", i)
            )
          )
        )
      },
    }
  }
}

//
// TTypeInfo
//

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct TTypeInfo {
  pub type_: Option<TDatumType>,
  pub nullable: Option<bool>,
  pub is_array: Option<bool>,
  pub encoding: Option<TEncodingType>,
  pub precision: Option<i32>,
  pub scale: Option<i32>,
  pub comp_param: Option<i32>,
  pub size: Option<i32>,
}

impl TTypeInfo {
  pub fn new<F1, F2, F3, F4, F5, F6, F7, F8>(type_: F1, nullable: F2, is_array: F3, encoding: F4, precision: F5, scale: F6, comp_param: F7, size: F8) -> TTypeInfo where F1: Into<Option<TDatumType>>, F2: Into<Option<bool>>, F3: Into<Option<bool>>, F4: Into<Option<TEncodingType>>, F5: Into<Option<i32>>, F6: Into<Option<i32>>, F7: Into<Option<i32>>, F8: Into<Option<i32>> {
    TTypeInfo {
      type_: type_.into(),
      nullable: nullable.into(),
      is_array: is_array.into(),
      encoding: encoding.into(),
      precision: precision.into(),
      scale: scale.into(),
      comp_param: comp_param.into(),
      size: size.into(),
    }
  }
  pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TTypeInfo> {
    i_prot.read_struct_begin()?;
    let mut f_1: Option<TDatumType> = None;
    let mut f_2: Option<bool> = Some(false);
    let mut f_3: Option<bool> = Some(false);
    let mut f_4: Option<TEncodingType> = None;
    let mut f_5: Option<i32> = Some(0);
    let mut f_6: Option<i32> = Some(0);
    let mut f_7: Option<i32> = Some(0);
    let mut f_8: Option<i32> = None;
    loop {
      let field_ident = i_prot.read_field_begin()?;
      if field_ident.field_type == TType::Stop {
        break;
      }
      let field_id = field_id(&field_ident)?;
      match field_id {
        1 => {
          let val = TDatumType::read_from_in_protocol(i_prot)?;
          f_1 = Some(val);
        },
        2 => {
          let val = i_prot.read_bool()?;
          f_2 = Some(val);
        },
        3 => {
          let val = i_prot.read_bool()?;
          f_3 = Some(val);
        },
        4 => {
          let val = TEncodingType::read_from_in_protocol(i_prot)?;
          f_4 = Some(val);
        },
        5 => {
          let val = i_prot.read_i32()?;
          f_5 = Some(val);
        },
        6 => {
          let val = i_prot.read_i32()?;
          f_6 = Some(val);
        },
        7 => {
          let val = i_prot.read_i32()?;
          f_7 = Some(val);
        },
        8 => {
          let val = i_prot.read_i32()?;
          f_8 = Some(val);
        },
        _ => {
          i_prot.skip(field_ident.field_type)?;
        },
      };
      i_prot.read_field_end()?;
    }
    i_prot.read_struct_end()?;
    let ret = TTypeInfo {
      type_: f_1,
      nullable: f_2,
      is_array: f_3,
      encoding: f_4,
      precision: f_5,
      scale: f_6,
      comp_param: f_7,
      size: f_8,
    };
    Ok(ret)
  }
  pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> {
    let struct_ident = TStructIdentifier::new("TTypeInfo");
    o_prot.write_struct_begin(&struct_ident)?;
    if let Some(ref fld_var) = self.type_ {
      o_prot.write_field_begin(&TFieldIdentifier::new("type", TType::I32, 1))?;
      fld_var.write_to_out_protocol(o_prot)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.nullable {
      o_prot.write_field_begin(&TFieldIdentifier::new("nullable", TType::Bool, 2))?;
      o_prot.write_bool(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.is_array {
      o_prot.write_field_begin(&TFieldIdentifier::new("is_array", TType::Bool, 3))?;
      o_prot.write_bool(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(ref fld_var) = self.encoding {
      o_prot.write_field_begin(&TFieldIdentifier::new("encoding", TType::I32, 4))?;
      fld_var.write_to_out_protocol(o_prot)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.precision {
      o_prot.write_field_begin(&TFieldIdentifier::new("precision", TType::I32, 5))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.scale {
      o_prot.write_field_begin(&TFieldIdentifier::new("scale", TType::I32, 6))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.comp_param {
      o_prot.write_field_begin(&TFieldIdentifier::new("comp_param", TType::I32, 7))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    if let Some(fld_var) = self.size {
      o_prot.write_field_begin(&TFieldIdentifier::new("size", TType::I32, 8))?;
      o_prot.write_i32(fld_var)?;
      o_prot.write_field_end()?;
      ()
    } else {
      ()
    }
    o_prot.write_field_stop()?;
    o_prot.write_struct_end()
  }
}

impl Default for TTypeInfo {
  fn default() -> Self {
    TTypeInfo{
      type_: None,
      nullable: Some(false),
      is_array: Some(false),
      encoding: None,
      precision: Some(0),
      scale: Some(0),
      comp_param: Some(0),
      size: Some(0),
    }
  }
}