No more distinction between internal/external protocol variants
This commit is contained in:
parent
9adabddf54
commit
ffae9be241
|
@ -13,6 +13,7 @@ use super::rewrite::CaveatError;
|
||||||
use super::rewrite::CheckedCaveat;
|
use super::rewrite::CheckedCaveat;
|
||||||
use super::schemas::sturdy;
|
use super::schemas::sturdy;
|
||||||
|
|
||||||
|
use preserves::value::ArcValue;
|
||||||
use preserves::value::Domain;
|
use preserves::value::Domain;
|
||||||
use preserves::value::IOValue;
|
use preserves::value::IOValue;
|
||||||
use preserves::value::Map;
|
use preserves::value::Map;
|
||||||
|
@ -53,7 +54,7 @@ use tracing::Instrument;
|
||||||
/// `M`-values can be exchanged among objects, for distributed or
|
/// `M`-values can be exchanged among objects, for distributed or
|
||||||
/// polyglot systems a *lingua franca* has to be chosen. `AnyValue` is
|
/// polyglot systems a *lingua franca* has to be chosen. `AnyValue` is
|
||||||
/// that language.
|
/// that language.
|
||||||
pub type AnyValue = super::schemas::internal_protocol::_Any;
|
pub type AnyValue = ArcValue<Arc<Cap>>;
|
||||||
|
|
||||||
/// The type of process-unique actor IDs.
|
/// The type of process-unique actor IDs.
|
||||||
pub type ActorId = u64;
|
pub type ActorId = u64;
|
||||||
|
@ -236,7 +237,7 @@ pub type PendingEventQueue = Vec<Action>;
|
||||||
/// values contained in an `Activation` are also sometimes useful.
|
/// values contained in an `Activation` are also sometimes useful.
|
||||||
///
|
///
|
||||||
/// This is what other implementations call a "Turn", renamed here to
|
/// This is what other implementations call a "Turn", renamed here to
|
||||||
/// avoid conflicts with [`crate::schemas::internal_protocol::Turn`].
|
/// avoid conflicts with [`crate::schemas::protocol::Turn`].
|
||||||
pub struct Activation<'activation> {
|
pub struct Activation<'activation> {
|
||||||
/// A reference to the currently active [`Facet`] and the implementation-side state of its
|
/// A reference to the currently active [`Facet`] and the implementation-side state of its
|
||||||
/// [`Actor`].
|
/// [`Actor`].
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
//! Actor errors.
|
//! Actor errors.
|
||||||
|
|
||||||
|
use super::actor::AnyValue;
|
||||||
use super::language;
|
use super::language;
|
||||||
use super::schemas::internal_protocol::_Any;
|
use super::schemas::protocol as P;
|
||||||
|
|
||||||
#[doc(inline)]
|
|
||||||
pub use super::schemas::internal_protocol::Error;
|
|
||||||
|
|
||||||
use preserves::value::NestedValue;
|
use preserves::value::NestedValue;
|
||||||
use preserves::value::Value;
|
use preserves::value::Value;
|
||||||
use preserves_schema::Codec;
|
use preserves_schema::Codec;
|
||||||
use preserves_schema::ParseError;
|
use preserves_schema::ParseError;
|
||||||
|
|
||||||
|
pub type Error = P::Error<AnyValue>;
|
||||||
|
|
||||||
impl std::error::Error for Error {}
|
impl std::error::Error for Error {}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
|
@ -22,10 +22,10 @@ impl std::fmt::Display for Error {
|
||||||
/// Construct an [`Error`] with the given `message` and `detail`.
|
/// Construct an [`Error`] with the given `message` and `detail`.
|
||||||
///
|
///
|
||||||
/// When no relevant detail exists, convention is to set `detail` to `false`.
|
/// When no relevant detail exists, convention is to set `detail` to `false`.
|
||||||
pub fn error<Detail>(message: &str, detail: Detail) -> Error where _Any: From<Detail> {
|
pub fn error<Detail>(message: &str, detail: Detail) -> Error where AnyValue: From<Detail> {
|
||||||
Error {
|
Error {
|
||||||
message: message.to_owned(),
|
message: message.to_owned(),
|
||||||
detail: _Any::from(detail),
|
detail: AnyValue::from(detail),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,15 +35,15 @@ pub fn error<Detail>(message: &str, detail: Detail) -> Error where _Any: From<De
|
||||||
/// Used primarily when attempting to perform an
|
/// Used primarily when attempting to perform an
|
||||||
/// [`Activation`][crate::actor::Activation] on an already-terminated
|
/// [`Activation`][crate::actor::Activation] on an already-terminated
|
||||||
/// actor.
|
/// actor.
|
||||||
pub fn encode_error(result: Result<(), Error>) -> _Any {
|
pub fn encode_error(result: Result<(), Error>) -> AnyValue {
|
||||||
match result {
|
match result {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let mut r = Value::record(_Any::symbol("Ok"), 1);
|
let mut r = Value::record(AnyValue::symbol("Ok"), 1);
|
||||||
r.fields_vec_mut().push(Value::record(_Any::symbol("tuple"), 0).finish().wrap());
|
r.fields_vec_mut().push(Value::record(AnyValue::symbol("tuple"), 0).finish().wrap());
|
||||||
r.finish().wrap()
|
r.finish().wrap()
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let mut r = Value::record(_Any::symbol("Err"), 1);
|
let mut r = Value::record(AnyValue::symbol("Err"), 1);
|
||||||
r.fields_vec_mut().push(language().unparse(&e));
|
r.fields_vec_mut().push(language().unparse(&e));
|
||||||
r.finish().wrap()
|
r.finish().wrap()
|
||||||
}
|
}
|
||||||
|
@ -52,24 +52,24 @@ pub fn encode_error(result: Result<(), Error>) -> _Any {
|
||||||
|
|
||||||
impl<'a> From<&'a str> for Error {
|
impl<'a> From<&'a str> for Error {
|
||||||
fn from(v: &'a str) -> Self {
|
fn from(v: &'a str) -> Self {
|
||||||
error(v, _Any::new(false))
|
error(v, AnyValue::new(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(v: std::io::Error) -> Self {
|
fn from(v: std::io::Error) -> Self {
|
||||||
error(&format!("{}", v), _Any::new(false))
|
error(&format!("{}", v), AnyValue::new(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ParseError> for Error {
|
impl From<ParseError> for Error {
|
||||||
fn from(v: ParseError) -> Self {
|
fn from(v: ParseError) -> Self {
|
||||||
error(&format!("{}", v), _Any::new(false))
|
error(&format!("{}", v), AnyValue::new(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<preserves::error::Error> for Error {
|
impl From<preserves::error::Error> for Error {
|
||||||
fn from(v: preserves::error::Error) -> Self {
|
fn from(v: preserves::error::Error) -> Self {
|
||||||
error(&format!("{}", v), _Any::new(false))
|
error(&format!("{}", v), AnyValue::new(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::during;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::error::error;
|
use crate::error::error;
|
||||||
use crate::schemas::gatekeeper;
|
use crate::schemas::gatekeeper;
|
||||||
use crate::schemas::internal_protocol as P;
|
use crate::schemas::protocol as P;
|
||||||
use crate::schemas::sturdy;
|
use crate::schemas::sturdy;
|
||||||
|
|
||||||
use futures::Sink;
|
use futures::Sink;
|
||||||
|
@ -93,7 +93,7 @@ pub struct TunnelRelay
|
||||||
inbound_assertions: Map</* remote */ P::Handle, (/* local */ Handle, Vec<Arc<WireSymbol>>)>,
|
inbound_assertions: Map</* remote */ P::Handle, (/* local */ Handle, Vec<Arc<WireSymbol>>)>,
|
||||||
outbound_assertions: Map<P::Handle, Vec<Arc<WireSymbol>>>,
|
outbound_assertions: Map<P::Handle, Vec<Arc<WireSymbol>>>,
|
||||||
membranes: Membranes,
|
membranes: Membranes,
|
||||||
pending_outbound: Vec<P::TurnEvent>,
|
pending_outbound: Vec<P::TurnEvent<AnyValue>>,
|
||||||
self_entity: Arc<Ref<()>>,
|
self_entity: Arc<Ref<()>>,
|
||||||
output: UnboundedSender<LoanedItem<Vec<u8>>>,
|
output: UnboundedSender<LoanedItem<Vec<u8>>>,
|
||||||
output_text: bool,
|
output_text: bool,
|
||||||
|
@ -251,7 +251,7 @@ impl TunnelRelay {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_one(&mut self, t: &mut Activation, bs: &[u8]) -> (Result<P::Packet, ParseError>, usize) {
|
fn deserialize_one(&mut self, t: &mut Activation, bs: &[u8]) -> (Result<P::Packet<AnyValue>, ParseError>, usize) {
|
||||||
let mut src = BytesBinarySource::new(&bs);
|
let mut src = BytesBinarySource::new(&bs);
|
||||||
let mut dec = ActivatedMembranes {
|
let mut dec = ActivatedMembranes {
|
||||||
turn: t,
|
turn: t,
|
||||||
|
@ -295,7 +295,7 @@ impl TunnelRelay {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_inbound_packet(&mut self, t: &mut Activation, p: P::Packet) -> ActorResult {
|
fn handle_inbound_packet(&mut self, t: &mut Activation, p: P::Packet<AnyValue>) -> ActorResult {
|
||||||
tracing::trace!(packet = ?p, "-->");
|
tracing::trace!(packet = ?p, "-->");
|
||||||
match p {
|
match p {
|
||||||
P::Packet::Error(b) => {
|
P::Packet::Error(b) => {
|
||||||
|
@ -397,7 +397,7 @@ impl TunnelRelay {
|
||||||
&mut self,
|
&mut self,
|
||||||
_t: &mut Activation,
|
_t: &mut Activation,
|
||||||
remote_oid: sturdy::Oid,
|
remote_oid: sturdy::Oid,
|
||||||
event: &P::Event,
|
event: &P::Event<AnyValue>,
|
||||||
) -> ActorResult {
|
) -> ActorResult {
|
||||||
match event {
|
match event {
|
||||||
P::Event::Assert(b) => {
|
P::Event::Assert(b) => {
|
||||||
|
@ -436,7 +436,7 @@ impl TunnelRelay {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_packet(&mut self, account: &Arc<Account>, cost: usize, p: P::Packet) -> ActorResult {
|
pub fn send_packet(&mut self, account: &Arc<Account>, cost: usize, p: P::Packet<AnyValue>) -> ActorResult {
|
||||||
let item = language().unparse(&p);
|
let item = language().unparse(&p);
|
||||||
tracing::trace!(packet = ?item, "<--");
|
tracing::trace!(packet = ?item, "<--");
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ impl TunnelRelay {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_event(&mut self, t: &mut Activation, remote_oid: sturdy::Oid, event: P::Event) -> ActorResult {
|
pub fn send_event(&mut self, t: &mut Activation, remote_oid: sturdy::Oid, event: P::Event<AnyValue>) -> ActorResult {
|
||||||
if self.pending_outbound.is_empty() {
|
if self.pending_outbound.is_empty() {
|
||||||
t.message_for_myself(&self.self_entity, ());
|
t.message_for_myself(&self.self_entity, ());
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ impl Membranes {
|
||||||
relay_ref: &TunnelRelayRef,
|
relay_ref: &TunnelRelayRef,
|
||||||
src: &'src mut S,
|
src: &'src mut S,
|
||||||
_read_annotations: bool,
|
_read_annotations: bool,
|
||||||
) -> io::Result<P::_Ptr> {
|
) -> io::Result<Arc<Cap>> {
|
||||||
let ws = match sturdy::WireRef::deserialize(&mut src.packed(NoEmbeddedDomainCodec))? {
|
let ws = match sturdy::WireRef::deserialize(&mut src.packed(NoEmbeddedDomainCodec))? {
|
||||||
sturdy::WireRef::Mine{ oid: b } => {
|
sturdy::WireRef::Mine{ oid: b } => {
|
||||||
let oid = *b;
|
let oid = *b;
|
||||||
|
@ -549,21 +549,21 @@ impl Membranes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'activation, 'm> DomainDecode<P::_Ptr> for ActivatedMembranes<'a, 'activation, 'm> {
|
impl<'a, 'activation, 'm> DomainDecode<Arc<Cap>> for ActivatedMembranes<'a, 'activation, 'm> {
|
||||||
fn decode_embedded<'de, 'src, S: BinarySource<'de>>(
|
fn decode_embedded<'de, 'src, S: BinarySource<'de>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
src: &'src mut S,
|
src: &'src mut S,
|
||||||
read_annotations: bool,
|
read_annotations: bool,
|
||||||
) -> io::Result<P::_Ptr> {
|
) -> io::Result<Arc<Cap>> {
|
||||||
self.membranes.decode_embedded(self.turn, self.tr_ref, src, read_annotations)
|
self.membranes.decode_embedded(self.turn, self.tr_ref, src, read_annotations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DomainEncode<P::_Ptr> for Membranes {
|
impl DomainEncode<Arc<Cap>> for Membranes {
|
||||||
fn encode_embedded<W: Writer>(
|
fn encode_embedded<W: Writer>(
|
||||||
&mut self,
|
&mut self,
|
||||||
w: &mut W,
|
w: &mut W,
|
||||||
d: &P::_Ptr,
|
d: &Arc<Cap>,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
w.write(&mut NoEmbeddedDomainCodec, &language().unparse(&match self.exported.ref_map.get(d) {
|
w.write(&mut NoEmbeddedDomainCodec, &language().unparse(&match self.exported.ref_map.get(d) {
|
||||||
Some(ws) => sturdy::WireRef::Mine {
|
Some(ws) => sturdy::WireRef::Mine {
|
||||||
|
|
Loading…
Reference in New Issue