Created
May 22, 2015 06:56
-
-
Save thehydroimpulse/3a4d8ceaadcb1ad9280a to your computer and use it in GitHub Desktop.
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
/// 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