Skip to content

Instantly share code, notes, and snippets.

@thehydroimpulse
Created May 22, 2015 06:56
Show Gist options
  • Save thehydroimpulse/3a4d8ceaadcb1ad9280a to your computer and use it in GitHub Desktop.
Save thehydroimpulse/3a4d8ceaadcb1ad9280a to your computer and use it in GitHub Desktop.
/// An example that somewhat translates Twitter's use of Thrift within the
/// FlockDb database to Thrust, a Rust implementation of Thrift.
/// This should illustrate the rough API that Thrust exposes and how code generation
/// using the `thrust!` procedural macro works.
extern crate thrust;
use thrust::{Server, ThriftResult};
use flockdb::thrift::{FlockDb};
thrust!("
namespace rust flockdb.thrift;
service FlockDB {
bool contains(1: i64 source_id, 2: i32 graph_id, 3: i64 destination_id);
}
");
impl FlockDb::Service for FlockDb::Server {
fn contains(source_id: i64, graph_id: i32, destination_id: i64) -> ThriftResult<bool> {
Ok(true)
}
}
fn main() {
let server = Server::new("localhost:8000", FlockDb::Server);
server.listen();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment