Update to Preserves 0.7
This commit is contained in:
parent
14b7aad9c6
commit
648fa58d3d
|
@ -727,9 +727,9 @@ checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "preserves"
|
name = "preserves"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9fab2d8978c0916b67126c6fcd927a37ecbaa6469dd18ec25dac346d61eca7bd"
|
checksum = "925929f873a9dff97fbe4e369e7ecfd3c950e315cbd4630a7856507134d0d810"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"num",
|
"num",
|
||||||
|
|
|
@ -18,7 +18,7 @@ lto = true
|
||||||
name = "syndicate"
|
name = "syndicate"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
preserves = "0.6.0"
|
preserves = "0.7.0"
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
serde_bytes = "0.11"
|
serde_bytes = "0.11"
|
||||||
|
|
|
@ -11,18 +11,25 @@ use futures::select;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use tokio::time::interval;
|
use tokio::time::interval;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn says(who: V, what: V) -> V {
|
||||||
|
let mut r = Value::simple_record("Says", 2);
|
||||||
|
r.fields_vec_mut().push(who);
|
||||||
|
r.fields_vec_mut().push(what);
|
||||||
|
r.finish().wrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let discard: V = Value::simple_record("discard", vec![]).wrap();
|
let discard: V = Value::simple_record0("discard").wrap();
|
||||||
let capture: V = Value::simple_record("capture", vec![discard]).wrap();
|
let capture: V = Value::simple_record1("capture", discard).wrap();
|
||||||
|
|
||||||
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
||||||
frames.send(C2S::Connect(Value::from("chat").wrap())).await?;
|
frames.send(C2S::Connect(Value::from("chat").wrap())).await?;
|
||||||
frames.send(
|
frames.send(
|
||||||
C2S::Turn(vec![Action::Assert(
|
C2S::Turn(vec![Action::Assert(
|
||||||
Value::from(0).wrap(),
|
Value::from(0).wrap(),
|
||||||
Value::simple_record("observe", vec![
|
Value::simple_record1("observe", says(capture.clone(), capture)).wrap())]))
|
||||||
Value::simple_record("Says", vec![capture.clone(), capture]).wrap()]).wrap())]))
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut stats_timer = interval(Duration::from_secs(1));
|
let mut stats_timer = interval(Duration::from_secs(1));
|
||||||
|
|
|
@ -87,13 +87,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
||||||
frames.send(C2S::Connect(Value::from(config.dataspace).wrap())).await?;
|
frames.send(C2S::Connect(Value::from(config.dataspace).wrap())).await?;
|
||||||
|
|
||||||
let discard = Value::simple_record("discard", vec![]).wrap();
|
let discard = Value::simple_record0("discard").wrap();
|
||||||
let capture = Value::simple_record("capture", vec![discard]).wrap();
|
let capture = Value::simple_record1("capture", discard).wrap();
|
||||||
frames.send(
|
frames.send(
|
||||||
C2S::Turn(vec![Action::Assert(
|
C2S::Turn(vec![Action::Assert(
|
||||||
Value::from(0).wrap(),
|
Value::from(0).wrap(),
|
||||||
Value::simple_record("observe", vec![
|
Value::simple_record1("observe",
|
||||||
Value::simple_record(recv_label, vec![capture]).wrap()]).wrap())]))
|
Value::simple_record1(recv_label, capture).wrap()).wrap())]))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut stats_timer = interval(Duration::from_secs(1));
|
let mut stats_timer = interval(Duration::from_secs(1));
|
||||||
|
@ -107,7 +107,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
current_stamp = Value::from(now()?).wrap();
|
current_stamp = Value::from(now()?).wrap();
|
||||||
for _ in 0..c.action_count {
|
for _ in 0..c.action_count {
|
||||||
actions.push(Action::Message(
|
actions.push(Action::Message(
|
||||||
Value::simple_record(send_label, vec![current_stamp.clone()]).wrap()));
|
Value::simple_record1(send_label, current_stamp.clone()).wrap()));
|
||||||
}
|
}
|
||||||
frames.send(C2S::Turn(actions)).await?;
|
frames.send(C2S::Turn(actions)).await?;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
Event::Msg(_, captures) => {
|
Event::Msg(_, captures) => {
|
||||||
if should_echo || (report_latency_every == 0) {
|
if should_echo || (report_latency_every == 0) {
|
||||||
actions.push(Action::Message(
|
actions.push(Action::Message(
|
||||||
Value::simple_record(send_label, vec![captures[0].clone()]).wrap()));
|
Value::simple_record1(send_label, captures[0].clone()).wrap()));
|
||||||
} else {
|
} else {
|
||||||
if !have_sample {
|
if !have_sample {
|
||||||
let rtt_ns = now()? - captures[0].value().to_u64()?;
|
let rtt_ns = now()? - captures[0].value().to_u64()?;
|
||||||
|
@ -154,7 +154,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
current_stamp = Value::from(now()?).wrap();
|
current_stamp = Value::from(now()?).wrap();
|
||||||
}
|
}
|
||||||
actions.push(Action::Message(
|
actions.push(Action::Message(
|
||||||
Value::simple_record(send_label, vec![current_stamp.clone()]).wrap()));
|
Value::simple_record1(send_label, current_stamp.clone()).wrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ =>
|
_ =>
|
||||||
|
|
|
@ -5,7 +5,7 @@ use tokio::net::TcpStream;
|
||||||
use tokio_util::codec::Framed;
|
use tokio_util::codec::Framed;
|
||||||
|
|
||||||
use syndicate::packets::{ClientCodec, C2S, S2C, Action};
|
use syndicate::packets::{ClientCodec, C2S, S2C, Action};
|
||||||
use syndicate::value::Value;
|
use syndicate::value::{Value, IOValue};
|
||||||
|
|
||||||
#[derive(Clone, Debug, StructOpt)]
|
#[derive(Clone, Debug, StructOpt)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
@ -13,6 +13,14 @@ pub struct Config {
|
||||||
action_count: u32,
|
action_count: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn says(who: IOValue, what: IOValue) -> IOValue {
|
||||||
|
let mut r = Value::simple_record("Says", 2);
|
||||||
|
r.fields_vec_mut().push(who);
|
||||||
|
r.fields_vec_mut().push(what);
|
||||||
|
r.finish().wrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = Config::from_args();
|
let config = Config::from_args();
|
||||||
|
@ -26,11 +34,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let mut actions = vec![];
|
let mut actions = vec![];
|
||||||
for _ in 0..config.action_count {
|
for _ in 0..config.action_count {
|
||||||
actions.push(Action::Message(
|
actions.push(Action::Message(says(Value::from("producer").wrap(),
|
||||||
Value::simple_record("Says", vec![
|
Value::from(counter).wrap())));
|
||||||
Value::from("producer").wrap(),
|
|
||||||
Value::from(counter).wrap(),
|
|
||||||
]).wrap()));
|
|
||||||
}
|
}
|
||||||
frames.send(C2S::Turn(actions)).await?;
|
frames.send(C2S::Turn(actions)).await?;
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,16 @@ use tokio::time::interval;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let discard: V = Value::simple_record("discard", vec![]).wrap();
|
let discard: V = Value::simple_record0("discard").wrap();
|
||||||
let capture: V = Value::simple_record("capture", vec![discard]).wrap();
|
let capture: V = Value::simple_record1("capture", discard).wrap();
|
||||||
|
|
||||||
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
let mut frames = Framed::new(TcpStream::connect("127.0.0.1:8001").await?, ClientCodec::new());
|
||||||
frames.send(C2S::Connect(Value::from("chat").wrap())).await?;
|
frames.send(C2S::Connect(Value::from("chat").wrap())).await?;
|
||||||
frames.send(
|
frames.send(
|
||||||
C2S::Turn(vec![Action::Assert(
|
C2S::Turn(vec![Action::Assert(
|
||||||
Value::from(0).wrap(),
|
Value::from(0).wrap(),
|
||||||
Value::simple_record("observe", vec![
|
Value::simple_record1("observe",
|
||||||
Value::simple_record("Present", vec![capture]).wrap()]).wrap())]))
|
Value::simple_record1("Present", capture).wrap()).wrap())]))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let mut stats_timer = interval(Duration::from_secs(1));
|
let mut stats_timer = interval(Duration::from_secs(1));
|
||||||
|
|
|
@ -13,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let present_action = Action::Assert(
|
let present_action = Action::Assert(
|
||||||
Value::from(0).wrap(),
|
Value::from(0).wrap(),
|
||||||
Value::simple_record("Present", vec![Value::from(std::process::id()).wrap()]).wrap());
|
Value::simple_record1("Present", Value::from(std::process::id()).wrap()).wrap());
|
||||||
let absent_action = Action::Clear(
|
let absent_action = Action::Clear(
|
||||||
Value::from(0).wrap());
|
Value::from(0).wrap());
|
||||||
|
|
||||||
|
|
|
@ -335,7 +335,7 @@ where FCont: FnMut(&mut Continuation, &CachedAssertion) -> (),
|
||||||
fn class_of(v: &Assertion) -> Option<Guard> {
|
fn class_of(v: &Assertion) -> Option<Guard> {
|
||||||
match v.value() {
|
match v.value() {
|
||||||
Value::Sequence(ref vs) => Some(Guard::Seq(vs.len())),
|
Value::Sequence(ref vs) => Some(Guard::Seq(vs.len())),
|
||||||
Value::Record((ref l, ref fs)) => Some(Guard::Rec(l.clone(), fs.len())),
|
Value::Record(ref r) => Some(Guard::Rec(r.label().clone(), r.arity())),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ fn project_paths<'a>(v: &'a Assertion, ps: &Paths) -> Captures {
|
||||||
fn step(v: &Assertion, i: usize) -> &Assertion {
|
fn step(v: &Assertion, i: usize) -> &Assertion {
|
||||||
match v.value() {
|
match v.value() {
|
||||||
Value::Sequence(ref vs) => &vs[i],
|
Value::Sequence(ref vs) => &vs[i],
|
||||||
Value::Record((_, ref fs)) => &fs[i],
|
Value::Record(ref r) => &r.fields()[i],
|
||||||
_ => panic!("step: non-sequence, non-record {:?}", v)
|
_ => panic!("step: non-sequence, non-record {:?}", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue