Struct Codec
#[non_exhaustive]pub struct Codec {
pub point: &'static str,
pub encode: fn(&(dyn Any + Sync + Send + 'static)) -> Option<String>,
pub decode: fn(&str) -> Result<Arc<dyn Any + Sync + Send>, String>,
pub fresh: fn() -> Box<dyn Any + Send>,
pub encode_value: Option<fn(&(dyn Any + Send + 'static)) -> Option<String>>,
pub decode_value: Option<fn(&str, &mut (dyn Any + Send + 'static)) -> Result<(), String>>,
pub clone_value: Option<fn(&(dyn Any + Send + 'static)) -> Box<dyn Any + Send>>,
}Expand description
How a relayable point’s input is written and read
(Relayed), and a relayable request’s value (RelayedRequest),
its types erased, for a contract table
(relayable). Two codecs
are equal when they are for the same point.
Build one with Codec::of (an event) or Codec::request (a
request).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.point: &'static strThe point it is for (Point::ID): declare_all
refuses a codec on another point (Refused::TypeMismatch).
encode: fn(&(dyn Any + Sync + Send + 'static)) -> Option<String>Writes an input.
decode: fn(&str) -> Result<Arc<dyn Any + Sync + Send>, String>Reads one back.
fresh: fn() -> Box<dyn Any + Send>Makes the value each listener fills when an event relayed in is
delivered (Relay::ingest), and the value a request answered
here starts from before its text is read into it.
encode_value: Option<fn(&(dyn Any + Send + 'static)) -> Option<String>>On a request’s codec, writes its value; None on an event’s.
decode_value: Option<fn(&str, &mut (dyn Any + Send + 'static)) -> Result<(), String>>On a request’s codec, reads its value back; None on an event’s.
clone_value: Option<fn(&(dyn Any + Send + 'static)) -> Box<dyn Any + Send>>On a request’s codec, copies its value (the far side runs an
alter emit, Bus::alter_any); None on
an event’s.