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::schemas::sturdy;
|
||||
|
||||
use preserves::value::ArcValue;
|
||||
use preserves::value::Domain;
|
||||
use preserves::value::IOValue;
|
||||
use preserves::value::Map;
|
||||
|
@ -53,7 +54,7 @@ use tracing::Instrument;
|
|||
/// `M`-values can be exchanged among objects, for distributed or
|
||||
/// polyglot systems a *lingua franca* has to be chosen. `AnyValue` is
|
||||
/// that language.
|
||||
pub type AnyValue = super::schemas::internal_protocol::_Any;
|
||||
pub type AnyValue = ArcValue<Arc<Cap>>;
|
||||
|
||||
/// The type of process-unique actor IDs.
|
||||
pub type ActorId = u64;
|
||||
|
@ -236,7 +237,7 @@ pub type PendingEventQueue = Vec<Action>;
|
|||
/// values contained in an `Activation` are also sometimes useful.
|
||||
///
|
||||
/// 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> {
|
||||
/// A reference to the currently active [`Facet`] and the implementation-side state of its
|
||||
/// [`Actor`].
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
//! Actor errors.
|
||||
|
||||
use super::actor::AnyValue;
|
||||
use super::language;
|
||||
use super::schemas::internal_protocol::_Any;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use super::schemas::internal_protocol::Error;
|
||||
use super::schemas::protocol as P;
|
||||
|
||||
use preserves::value::NestedValue;
|
||||
use preserves::value::Value;
|
||||
use preserves_schema::Codec;
|
||||
use preserves_schema::ParseError;
|
||||
|
||||
pub type Error = P::Error<AnyValue>;
|
||||
|
||||
impl std::error::Error 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`.
|
||||
///
|
||||
/// 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 {
|
||||
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
|
||||
/// [`Activation`][crate::actor::Activation] on an already-terminated
|
||||
/// actor.
|
||||
pub fn encode_error(result: Result<(), Error>) -> _Any {
|
||||
pub fn encode_error(result: Result<(), Error>) -> AnyValue {
|
||||
match result {
|
||||
Ok(()) => {
|
||||
let mut r = Value::record(_Any::symbol("Ok"), 1);
|
||||
r.fields_vec_mut().push(Value::record(_Any::symbol("tuple"), 0).finish().wrap());
|
||||
let mut r = Value::record(AnyValue::symbol("Ok"), 1);
|
||||
r.fields_vec_mut().push(Value::record(AnyValue::symbol("tuple"), 0).finish().wrap());
|
||||
r.finish().wrap()
|
||||
}
|
||||
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.finish().wrap()
|
||||
}
|
||||
|
@ -52,24 +52,24 @@ pub fn encode_error(result: Result<(), Error>) -> _Any {
|
|||
|
||||
impl<'a> From<&'a str> for Error {
|
||||
fn from(v: &'a str) -> Self {
|
||||
error(v, _Any::new(false))
|
||||
error(v, AnyValue::new(false))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for Error {
|
||||
fn from(v: std::io::Error) -> Self {
|
||||
error(&format!("{}", v), _Any::new(false))
|
||||
error(&format!("{}", v), AnyValue::new(false))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParseError> for Error {
|
||||
fn from(v: ParseError) -> Self {
|
||||
error(&format!("{}", v), _Any::new(false))
|
||||
error(&format!("{}", v), AnyValue::new(false))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<preserves::error::Error> for Error {
|
||||
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::schemas::gatekeeper;
|
||||
use crate::schemas::internal_protocol as P;
|
||||
use crate::schemas::protocol as P;
|
||||
use crate::schemas::sturdy;
|
||||
|
||||
use futures::Sink;
|
||||
|
@ -93,7 +93,7 @@ pub struct TunnelRelay
|
|||
inbound_assertions: Map</* remote */ P::Handle, (/* local */ Handle, Vec<Arc<WireSymbol>>)>,
|
||||
outbound_assertions: Map<P::Handle, Vec<Arc<WireSymbol>>>,
|
||||
membranes: Membranes,
|
||||
pending_outbound: Vec<P::TurnEvent>,
|
||||
pending_outbound: Vec<P::TurnEvent<AnyValue>>,
|
||||
self_entity: Arc<Ref<()>>,
|
||||
output: UnboundedSender<LoanedItem<Vec<u8>>>,
|
||||
output_text: bool,
|
||||
|
@ -251,7 +251,7 @@ impl TunnelRelay {
|
|||
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 dec = ActivatedMembranes {
|
||||
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, "-->");
|
||||
match p {
|
||||
P::Packet::Error(b) => {
|
||||
|
@ -397,7 +397,7 @@ impl TunnelRelay {
|
|||
&mut self,
|
||||
_t: &mut Activation,
|
||||
remote_oid: sturdy::Oid,
|
||||
event: &P::Event,
|
||||
event: &P::Event<AnyValue>,
|
||||
) -> ActorResult {
|
||||
match event {
|
||||
P::Event::Assert(b) => {
|
||||
|
@ -436,7 +436,7 @@ impl TunnelRelay {
|
|||
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);
|
||||
tracing::trace!(packet = ?item, "<--");
|
||||
|
||||
|
@ -452,7 +452,7 @@ impl TunnelRelay {
|
|||
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() {
|
||||
t.message_for_myself(&self.self_entity, ());
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ impl Membranes {
|
|||
relay_ref: &TunnelRelayRef,
|
||||
src: &'src mut S,
|
||||
_read_annotations: bool,
|
||||
) -> io::Result<P::_Ptr> {
|
||||
) -> io::Result<Arc<Cap>> {
|
||||
let ws = match sturdy::WireRef::deserialize(&mut src.packed(NoEmbeddedDomainCodec))? {
|
||||
sturdy::WireRef::Mine{ 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>>(
|
||||
&mut self,
|
||||
src: &'src mut S,
|
||||
read_annotations: bool,
|
||||
) -> io::Result<P::_Ptr> {
|
||||
) -> io::Result<Arc<Cap>> {
|
||||
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>(
|
||||
&mut self,
|
||||
w: &mut W,
|
||||
d: &P::_Ptr,
|
||||
d: &Arc<Cap>,
|
||||
) -> io::Result<()> {
|
||||
w.write(&mut NoEmbeddedDomainCodec, &language().unparse(&match self.exported.ref_map.get(d) {
|
||||
Some(ws) => sturdy::WireRef::Mine {
|
||||
|
|
Loading…
Reference in New Issue