Skip to content

Instantly share code, notes, and snippets.

View jamwt's full-sized avatar

Jamie Turner jamwt

View GitHub Profile
//! Safe cryptographic random number generation in Rust.
//! Works on Windows, Mac, Linux, FreeBSD, etc.
extern crate rand; // https://crates.io/crates/rand
use rand::{Rng}; // The generic trait all random generators support.
use rand::os::{OsRng}; // Specific implementation of above for strong crypto.
fn main() {
// OsRng is a type of `Rng` that wraps /dev/urandom, getrandom(), etc.
let mut r = OsRng::new().unwrap();
use std::sync::mpsc;
use futures::{
Future,
};
use futures::stream::{
Stream,
};
pub fn await_stream<T: Send + 'static, S: Stream<Item=T>>(stream: S) -> (Option<T>, S) {
93.86% (2,658B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->63.81% (1,807B) 0x50DE0DF: __tzfile_read (tzfile.c:278)
| ->63.81% (1,807B) 0x50DD7AE: tzset_internal (tzset.c:447)
| ->63.81% (1,807B) 0x50DDAD1: __tz_convert (tzset.c:632)
| ->63.81% (1,807B) 0x3137D6: sys::inner::time_to_utc_tm::h9f3b17d1c988fbc4bdc (sys.rs:74)
| ->63.81% (1,807B) 0x313605: at_utc::h75627e03dc1df4c1t1c (lib.rs:399)
thread '<main>' panicked at '[BUG] at this point there should always be a message: 1', ../src/libcore/option.rs:330
stack backtrace:
1: 0x7f8eb8b7d98e - sys::backtrace::write::h42ae15d4d8dc9021Lqs
2: 0x7f8eb8b810d5 - panicking::on_panic::h16e339088a7da9f0l8w
3: 0x7f8eb8b7736e - rt::unwind::begin_unwind_inner::hb0ccf650c87729feZNw
4: 0x7f8eb8b77ccc - rt::unwind::begin_unwind_fmt::he51a7264215a12fc5Mw
5: 0x7f8eb8b80ac6 - rust_begin_unwind
6: 0x7f8eb8bac824 - panicking::panic_fmt::h6cd1cd2e7f8c91c019B
7: 0x7f8eb8b729ce - event_loop::EventLoop<H>::run_once::h15461418731634333358
8: 0x7f8eb8b66b10 - main::hb66fa02c4781964cCda
extern crate eventual;
extern crate mio;
use std::collections::HashMap;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::thread;
use eventual::Async;
static COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
I0715 20:02:48.521234 04193 common.go:198] MP version: HEAD
=== RUN Test
I0715 20:02:48.521927 04193 all_test.go:37] Using seed: 1436990568521926197
I0715 20:02:49.451336 04193 osd2.go:48] Using tmp dir: /tmp/osd2-tests633816670
I0715 20:02:49.496960 <main> src/bin/osd2_init.rs:50] Creating cache file
I0715 20:02:49.497218 <main> src/bin/osd2_init.rs:55] Wrapping cache with an allocator
I0715 20:02:49.499978 <main> src/bin/osd2_init.rs:86] Setting up disk with 1GB seq zone size
I0715 20:02:49.502291 <main> src/bin/osd2_init.rs:88] Creating disk backed by file medium of size 5368709120
I0715 20:02:49.505049 <main> src/bin/osd2_init.rs:95] Device info: <ZonedDevice block-size=4096B device-size=5120MiB zones=5> on <FileMedium /tmp/osd2-tests633816670/disk>
I0715 20:02:49.508170 <main> src/bin/osd2_init.rs:105] Found conventional zone 0, initializing a dynamic allocator around it
vagrant@dbdev:/srv/rust-server/dropbox/util$ cargo build
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling yaml v0.1.4 (file:///srv/rust-server/dropbox/util)
Compiling bytes v0.2.9 (file:///srv/rust-server/dropbox/util)
Compiling backtrace-sys v0.1.1 (file:///srv/rust-server/dropbox/util)
Compiling clock_ticks v0.0.5 (file:///srv/rust-server/dropbox/util)
Compiling nix v0.3.8 (file:///srv/rust-server/dropbox/util)
Compiling openssl-sys v0.6.1 (file:///srv/rust-server/dropbox/util)
Compiling syncbox v0.2.3 (file:///srv/rust-server/dropbox/util)
Compiling backtrace v0.1.1 (file:///srv/rust-server/dropbox/util)
thread '<main>' panicked at '[BUG] at this point there should always be a message', ../src/libcore/option.rs:330
thread '<main>' panicked at 'Invalid value', /srv/rust-server/.fyre/rufio/src/lib.rs:238
stack backtrace:
1: 0x7fe36bc50b5e - sys::backtrace::write::h42ae15d4d8dc9021Lqs
2: 0x7fe36bc544eb - panicking::on_panic::h16e339088a7da9f0l8w
3: 0x7fe36bc4afde - rt::unwind::begin_unwind_inner::hb0ccf650c87729feZNw
4: 0x7fe36bc049d6 - rt::unwind::begin_unwind::h11844382485826230408
at ../src/libstd/rt/unwind/mod.rs:226
5: 0x7fe36bc25fb8 - future::Future<T, E>.Async::ready::closure.6967
at /srv/rust-server/dropbox/http/<std macros>:3
me:
foo: "==3.0.8",
bar: "==4.0.7",
bar:
foo: "3.0.X"
Day 1: foo is 3.0.8. we're all good
Day 2: cargo update, foo 3.0.9 is available.
[[package]]
name = "mio"
version = "0.2.1"
source = "git+https://github.com/carllerche/mio.git#e0afd68779f3a4f74d2c4b021e4cc5fdb01e557f"
dependencies = [
"bytes 0.1.3 (git+https://github.com/carllerche/bytes)",
"log 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.2.3 (git+https://github.com/carllerche/nix-rust)",
"time 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
]