Skip to content

Instantly share code, notes, and snippets.

View allengeorge's full-sized avatar

Allen George allengeorge

  • New York, NY, USA
View GitHub Profile
@allengeorge
allengeorge / error_message
Last active January 31, 2017 13:39
Problems with inferring type
error[E0282]: unable to infer enough type information about `_`
--> src/transport/buffered.rs:309:17
|
309 | let r = TBufferedReader::new(Box::new(r));
| ^^^^^^^^^^^^^^^^^^^^ cannot infer type for `_`
|
= note: type annotations or generic parameter binding required
error: aborting due to previous error
Compiling thrift v1.0.0 (file:///Users/allen/src/rust_projects/thrift/lib/rs)
error[E0277]: the trait bound `protocol::TInputProtocol: std::marker::Send` is not satisfied
--> src/server/threaded.rs:161:34
|
161 | let handle = thread::spawn(move || handle_incoming_connection(p, i_prot, o_prot));
| ^^^^^^^^^^^^^ the trait `std::marker::Send` is not implemented for `protocol::TInputProtocol`
|
= note: `protocol::TInputProtocol` cannot be sent between threads safely
= note: required because it appears within the type `Box<protocol::TInputProtocol>`
= note: required because it appears within the type `[closure@src/server/threaded.rs:161:48: 161:101 p:&mut PR, i_prot:Box<protocol::TInputProtocol>, o_prot:Box<protocol::TOutputProtocol>]`
@allengeorge
allengeorge / shared.rs
Created January 26, 2017 17:24
Thrift Rust
// Autogenerated by Thrift Compiler (1.0.0-dev)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, type_complexity))]
extern crate ordered_float;
extern crate thrift;
extern crate try_from;
error[E0308]: mismatched types
--> src/base_two.rs:453:49
|
453 | TRamenServiceActualProcessor::process_ramen(self.handler, incoming_sequence_number, i_prot, o_prot)
| ^^^^^^^^^^^^ expected &mut _, found type parameter
|
= note: expected type `&mut _`
= note: found type `H`
error: no field `o_prot` on type `&mut rift::protocol::TThriftClient + 'static`
--> error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'failed to emit error: Resource temporarily unavailable (os error 35)', ../src/librustc_errors/emitter.rs:713
note: Run with `RUST_BACKTRACE=1` for a backtrace.
fn write_bool(&mut self, b: bool) -> ::Result<()> {
match self.pending_write_bool_field_identifier {
Some(pending) => {
let field_id = pending.id.expect("bool field should have a field id");
let field_type_as_u8 = if b {
0x01
} else {
0x02
};
try!(self.write_field_header(field_type_as_u8, field_id));
@allengeorge
allengeorge / thrift_test.rs
Created December 18, 2016 17:09
Auto-generated rust code for ThriftTest.thrift
// Autogenerated by Thrift Compiler (0.10.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#![allow(unused_imports)]
extern crate ordered_float;
extern crate rift;
extern crate try_from;
use ordered_float::OrderedFloat;
//
// SecondService service client
//
pub trait TAbstractSecondServiceSyncClient {
fn blah_blah(&mut self) -> rift::Result<()>;
fn secondtest_string(&mut self, thing: String) -> rift::Result<String>;
}
pub struct TSecondServiceSyncClient {
/// A transport that performs I/O operations
/// to/from an intermediate buffer to avoid hitting
/// the underlying transport unnecessarily. All writes
/// are written to this object's intermediate
/// buffer and only written to the underlying transport
/// on a `flush`. All reads first fill this object's
/// intermediate buffer, and are served from there.
pub struct TBufferedTransport<I: TTransport> {
rbuf: Box<[u8]>,
rpos: usize,
pub struct TBinaryProtocol {
/// Set to `true` if the strict binary protocol is to be used.
pub strict: bool,
/// Underlying transport used to read protocol bytes from, and write protocol bytes to.
pub transport: Rc<RefCell<Box<TTransport>>>,
}
#[test]
fn must_write_correct_strict_call_message_header() {