Skip to content

Instantly share code, notes, and snippets.

@alex-shapiro
alex-shapiro / msgpack.rs
Last active August 14, 2017 17:05
custom Diesel type for MsgPack-encodable values
//! Custom Diesel type for mapping MsgPack-encodable values to
//! a binary row in an SQLite database.
use diesel::backend::Backend;
use diesel::expression::AsExpression;
use diesel::expression::NonAggregate;
use diesel::expression::bound::Bound;
use diesel::Queryable;
use diesel::row::Row;
use diesel::sqlite::Sqlite;
@alex-shapiro
alex-shapiro / and_select.rs
Created July 26, 2017 13:57
An "AND" version of the futures stream combinator
//! An adapter for merging the output of two streams, where
//! the stream resolves as soon either stream resolves.
use futures::{Poll, Async};
use futures::stream::{Stream, Fuse};
pub struct AndSelect<S1, S2> {
stream1: Fuse<S1>,
stream2: Fuse<S2>,
flag: bool,