This file contains hidden or 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
extern crate bn; | |
extern crate rand; | |
extern crate sodiumoxide; | |
mod sighash; | |
use bn::*; | |
use sodiumoxide::crypto::stream::{self,chacha20}; | |
use std::str; |
This file contains hidden or 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
macro_rules! separated_list2 ( | |
($i:expr, $sep:ident!( $($args:tt)* ), $submac:ident!( $($args2:tt)* )) => ( | |
{ | |
let mut res = ::std::vec::Vec::new(); | |
let mut input = $i; | |
// get the first element | |
let first = $submac!(input, $($args2)*); | |
if let $crate::IResult::Done(i,o) = first { |
This file contains hidden or 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
#[macro_use] | |
extern crate nom; | |
use nom::IResult; | |
macro_rules! n ( | |
($name:ident( $i:ty ) -> $o:ty, $submac:ident!( $($args:tt)* )) => ( | |
fn $name( i: $i ) -> std::result::Result<nom::IResult<$i,$o,u32>, nom::Err<$i, u32>> { | |
std::result::Result::Ok($submac!(i, $($args)*)) | |
} |
This file contains hidden or 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
; ModuleID = 'nom_http.0.rs' | |
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-apple-darwin" | |
%"9.nom::internal::IResult<&'static [u8], &'static [u8], u32>" = type { i64, [0 x i64], [5 x i64] } | |
%"2.core::ops::RangeTo<usize>" = type { i64 } | |
%"2.core::ops::Range<usize>" = type { i64, i64 } | |
%"9.nom::util::ErrorKind<u32>" = type { i32, [0 x i32], [1 x i32] } | |
%"2.core::ops::RangeFrom<usize>" = type { i64 } | |
%"9.nom::internal::Err<&'static [u8], u32>" = type { i8, [7 x i8], [4 x i64] } |
This file contains hidden or 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
// Context: | |
// * Rust n'a pas de TCO, donc on ne peut pas faire de récursion facilement | |
// * la gestion de l'ownership fait que le résultat d'une passe sur le | |
// contenu du Producer ne vivra pas plus longtemps que son buffer (sauf si on cpone les données) | |
// * les Producers et Consumers actuels passent leur temps à copier des buffers, | |
// je veux limiter ça au Producer | |
type Computation<I,O,S,E> = Fn(S, Input<I>) -> (I,Consumer<I,O,S,E>); | |
enum Input<I> { |
This file contains hidden or 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
#![feature(test)] | |
extern crate test; | |
use test::Bencher; | |
#[macro_use] | |
extern crate nom; | |
use nom::IResult; | |
use std::env; | |
use std::fs::File; |
This file contains hidden or 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 enum Err<'a,P=&'a[u8]> { | |
Code(u32), | |
Node(u32,Box<Err<'a>>), | |
Position(u32,P) | |
} | |
pub enum IResult<'a,I,O> { | |
Done(I,O), | |
Error(Err<'a>) | |
} |
This file contains hidden or 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
# What you need to write low level Rust code | |
* do not use cargo, use rustc directly to build your code | |
* you need to use a target.json file describing your target platform (example: https://github.com/hackndev/zinc/blob/master/thumbv6-none-eabi.json ). Pass it to rustc via --target=target.json | |
* you wan work without the standard library, by following those instructions: https://doc.rust-lang.org/book/no-stdlib.html | |
* |
This file contains hidden or 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 enum State { | |
A, | |
B(u8), | |
C(u8), | |
D | |
Error | |
} | |
enum Output { | |
X(u8), |
This file contains hidden or 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 type Fun<'a> = Box<FnOnce(u8) -> Res<'a> +'a>; | |
pub enum Res<'a> { | |
Done(u8, u8), | |
Incomplete(Fun<'a>) | |
} | |
pub trait FMap { | |
fn fmap<'y,F: Fn(u8) -> u8 + 'y>(self, f: &'y F) -> Res<'y>; | |
} |