rpc: use async-recursion
This commit is contained in:
parent
f0588c49ed
commit
7df6ab2149
src
12
src/Cargo.lock
generated
12
src/Cargo.lock
generated
@ -1,5 +1,16 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "async-recursion"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5444eec77a9ec2bfe4524139e09195862e981400c4358d3b760cae634e4c4ee"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.0"
|
||||
@ -337,6 +348,7 @@ checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211"
|
||||
name = "runtime"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"byteorder",
|
||||
"core_io",
|
||||
"cslice",
|
||||
|
@ -18,6 +18,7 @@ core_io = { version = "0.1", features = ["alloc", "collections"] }
|
||||
byteorder = { version = "1.3", default-features = false }
|
||||
void = { version = "1", default-features = false }
|
||||
futures = { version = "0.3", default-features = false, features = ["async-await"] }
|
||||
async-recursion = "0.3"
|
||||
libboard_zynq = { git = "https://git.m-labs.hk/M-Labs/zc706.git" }
|
||||
libsupport_zynq = { git = "https://git.m-labs.hk/M-Labs/zc706.git" }
|
||||
libcortex_a9 = { git = "https://git.m-labs.hk/M-Labs/zc706.git" }
|
||||
|
@ -2,15 +2,18 @@ use core::str;
|
||||
use cslice::{CSlice, CMutSlice};
|
||||
use log::debug;
|
||||
|
||||
use core_io::{Write, Error};
|
||||
use libboard_zynq::smoltcp;
|
||||
use libasync::smoltcp::TcpStream;
|
||||
use core_io::{Write, Error};
|
||||
use alloc::boxed::Box;
|
||||
use async_recursion::async_recursion;
|
||||
|
||||
use crate::proto_core_io::ProtoWrite;
|
||||
use crate::proto_async;
|
||||
use self::tag::{Tag, TagIterator, split_tag};
|
||||
|
||||
async unsafe fn recv_value(stream: &TcpStream, tag: Tag<'_>, data: &mut *mut (),
|
||||
#[async_recursion(?Send)]
|
||||
async unsafe fn recv_value(stream: &TcpStream, tag: Tag<'async_recursion>, data: &mut *mut (),
|
||||
alloc: &dyn Fn(usize) -> *mut ())
|
||||
-> Result<(), smoltcp::Error>
|
||||
{
|
||||
@ -51,7 +54,7 @@ async unsafe fn recv_value(stream: &TcpStream, tag: Tag<'_>, data: &mut *mut (),
|
||||
let mut it = it.clone();
|
||||
for _ in 0..arity {
|
||||
let tag = it.next().expect("truncated tag");
|
||||
//TODO: recv_value(reader, tag, data, alloc)?
|
||||
recv_value(stream, tag, data, alloc).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -65,16 +68,16 @@ async unsafe fn recv_value(stream: &TcpStream, tag: Tag<'_>, data: &mut *mut (),
|
||||
|
||||
let mut data = (*ptr).elements;
|
||||
for _ in 0..(*ptr).length as usize {
|
||||
//TODO: recv_value(reader, tag, &mut data, alloc).await?
|
||||
recv_value(stream, tag, &mut data, alloc).await?
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
Tag::Range(it) => {
|
||||
let tag = it.clone().next().expect("truncated tag");
|
||||
/*TODO: recv_value(reader, tag, data, alloc).await?;
|
||||
recv_value(reader, tag, data, alloc).await?;
|
||||
recv_value(reader, tag, data, alloc).await?;*/
|
||||
recv_value(stream, tag, data, alloc).await?;
|
||||
recv_value(stream, tag, data, alloc).await?;
|
||||
recv_value(stream, tag, data, alloc).await?;
|
||||
Ok(())
|
||||
}
|
||||
Tag::Keyword(_) => unreachable!(),
|
||||
|
Loading…
Reference in New Issue
Block a user