Skip to content

Instantly share code, notes, and snippets.

View aep's full-sized avatar
🥬

Arvid E. Picciani aep

🥬
View GitHub Profile
@aep
aep / main.rs
Created February 9, 2019 13:39
#![feature(futures_api, async_await, await_macro, arbitrary_self_types)]
#[macro_use]
extern crate lazy_static;
use std::future::{Future};
use std::task::{Poll};
use std::pin::Pin;
use std::{thread, time};
use std::sync::mpsc;
@aep
aep / main.rs
Created February 5, 2019 09:04
#[osaka]
fn foo(poll: Poll, a: Stream, b: Stream) {
loop {
let again = match a.read() {
Ready => do something,
Again => a,
};
match b.read() {
Ready => do something
Again => yield a.merge(b)
#[osaka]
fn foo(poll: Poll, a: Stream, b: Stream) {
loop {
let again = match a.read() {
Ready => do something,
Again => a,
};
match b.read() {
Ready => do something
Again => yield a.merge(b)
@aep
aep / main.rs
Created January 18, 2019 14:08
loop {
match info_req.try_recv() {
Err(std::sync::mpsc::TryRecvError::Empty) => (),
Err(std::sync::mpsc::TryRecvError::Disconnected) => break,
Ok(v) => {
info!("got req for {}", v.0);
ep.connect(v.0.clone())?;
open_connects.insert(v.0, (v.1, ));
}
};
secret = "your secret"
[publish]
shadow = "your shadow public key"
[[authorize]]
identity = "your own public key"
resource = "*"
aep@stark: ~/proj/devguard/carrier2 RUST_LOG=carrier cargo run
Compiling carrier-core v0.8.0 (/home/aep/proj/devguard/carrier2)
error[E0277]: the size for values of type `(dyn endpoint::Driver + 'static)` cannot be known at compilation time
--> src/main.rs:96:18
|
96 | let mut ep = osaka::sync!(ep).run();
| ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within `endpoint::Endpoint<PublisherDriver>`, the trait `std::marker::Sized` is not implemented for `(dyn endpoint::Driver + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
use dns::DnsRecord;
use error::Error;
use clock;
use osaka::mio::net::UdpSocket;
use osaka::osaka;
use noise;
use proto;
use identity;
use keystore;
use std::time::{Duration};
181 | let sock = UdpSocket::bind(&"0.0.0.0:0".parse().unwrap()).map_err(|e| Error::Io(e))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: within `endpoint::Endpoint<_>`, the trait `std::marker::Sized` is not implemented for `(dyn endpoint::Driver + 'static)`
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because it appears within the type `endpoint::Endpoint<_>`
= note: required because of the requirements on the impl of `std::ops::Try` for `std::result::Result<endpoint::Endpoint<_>, error::Error>`
@aep
aep / combinators.rs
Last active November 13, 2018 19:29
/// this is describes how to build typed combinators to a friend
/// he wanted to build a generic job executor thing that can execute one step at a time and forward
/// the intermediate data to the next step without copying
/// but all type safe of course.
///
/// my approach is sort of a practical take on category theory that rust does with for example futures
use carrier::*;
use futures::{Future, Sink, Stream};
use failure::Error;
use diesel::{self, RunQueryDsl};
use std::env;
use std::time::{SystemTime};
use std::sync::Mutex;
use futures::sync::mpsc;
use std::mem;
use std::thread;