Created
February 23, 2020 18:26
-
-
Save jonvuri/9b9a6783b45f46a6dd917373cd44b60b to your computer and use it in GitHub Desktop.
Thrift module path issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(too_many_arguments, 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; | |
use common; | |
// use crate::common; | |
// | |
// TFit | |
// | |
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] | |
pub struct TFit { | |
pub gender: Option<common::TGender>, | |
pub size: Option<common::TSize>, | |
} | |
impl TFit { | |
pub fn new<F1, F2>(gender: F1, size: F2) -> TFit where F1: Into<Option<common::TGender>>, F2: Into<Option<common::TSize>> { | |
TFit { | |
gender: gender.into(), | |
size: size.into(), | |
} | |
} | |
pub fn read_from_in_protocol(i_prot: &mut dyn TInputProtocol) -> thrift::Result<TFit> { | |
i_prot.read_struct_begin()?; | |
let mut f_1: Option<common::TGender> = None; | |
let mut f_2: Option<common::TSize> = 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 = common::TGender::read_from_in_protocol(i_prot)?; | |
f_1 = Some(val); | |
}, | |
2 => { | |
let val = common::TSize::read_from_in_protocol(i_prot)?; | |
f_2 = Some(val); | |
}, | |
_ => { | |
i_prot.skip(field_ident.field_type)?; | |
}, | |
}; | |
i_prot.read_field_end()?; | |
} | |
i_prot.read_struct_end()?; | |
let ret = TFit { | |
gender: f_1, | |
size: f_2, | |
}; | |
Ok(ret) | |
} | |
pub fn write_to_out_protocol(&self, o_prot: &mut dyn TOutputProtocol) -> thrift::Result<()> { | |
let struct_ident = TStructIdentifier::new("TFit"); | |
o_prot.write_struct_begin(&struct_ident)?; | |
if let Some(ref fld_var) = self.gender { | |
o_prot.write_field_begin(&TFieldIdentifier::new("gender", TType::I32, 1))?; | |
fld_var.write_to_out_protocol(o_prot)?; | |
o_prot.write_field_end()?; | |
() | |
} else { | |
() | |
} | |
if let Some(ref fld_var) = self.size { | |
o_prot.write_field_begin(&TFieldIdentifier::new("size", TType::I32, 2))?; | |
fld_var.write_to_out_protocol(o_prot)?; | |
o_prot.write_field_end()?; | |
() | |
} else { | |
() | |
} | |
o_prot.write_field_stop()?; | |
o_prot.write_struct_end() | |
} | |
} | |
impl Default for TFit { | |
fn default() -> Self { | |
TFit{ | |
gender: None, | |
size: None, | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "common.thrift" | |
struct TFit { | |
1: common.TGender gender | |
2: common.TSize size | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(too_many_arguments, 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 TGender { | |
Male = 0, | |
Female = 1, | |
Unisex = 2, | |
} | |
impl TGender { | |
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<TGender> { | |
let enum_value = i_prot.read_i32()?; | |
TGender::try_from(enum_value) } | |
} | |
impl TryFrom<i32> for TGender { | |
type Error = thrift::Error; fn try_from(i: i32) -> Result<Self, Self::Error> { | |
match i { | |
0 => Ok(TGender::Male), | |
1 => Ok(TGender::Female), | |
2 => Ok(TGender::Unisex), | |
_ => { | |
Err( | |
thrift::Error::Protocol( | |
ProtocolError::new( | |
ProtocolErrorKind::InvalidData, | |
format!("cannot convert enum constant {} to TGender", i) | |
) | |
) | |
) | |
}, | |
} | |
} | |
} | |
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] | |
pub enum TSize { | |
Small = 0, | |
Medium = 1, | |
Large = 2, | |
} | |
impl TSize { | |
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<TSize> { | |
let enum_value = i_prot.read_i32()?; | |
TSize::try_from(enum_value) } | |
} | |
impl TryFrom<i32> for TSize { | |
type Error = thrift::Error; fn try_from(i: i32) -> Result<Self, Self::Error> { | |
match i { | |
0 => Ok(TSize::Small), | |
1 => Ok(TSize::Medium), | |
2 => Ok(TSize::Large), | |
_ => { | |
Err( | |
thrift::Error::Protocol( | |
ProtocolError::new( | |
ProtocolErrorKind::InvalidData, | |
format!("cannot convert enum constant {} to TSize", i) | |
) | |
) | |
) | |
}, | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TGender { | |
MALE, | |
FEMALE, | |
UNISEX | |
} | |
enum TSize { | |
SMALL, | |
MEDIUM, | |
LARGE | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
pub mod common; | |
pub mod clothing; | |
pub mod client { | |
use clothing::TFit; | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment