Fold the fragmented distribution swim/routing/gossip tests into swim_core, routing, and swim_actor. Prune the dashboard tui and command surfaces. Add mvp-system actors (node_agent, orchestrator, stage_controller), the local_e2e harness, and gpu worker e2e. Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
27 lines
685 B
Rust
27 lines
685 B
Rust
use std::marker::PhantomData;
|
|
|
|
use serde::Serialize;
|
|
use serde::de::DeserializeOwned;
|
|
use swactor::Error;
|
|
use swactor_transport::Codec;
|
|
|
|
pub struct JsonCodec<M>(PhantomData<M>);
|
|
|
|
impl<M> Default for JsonCodec<M> {
|
|
fn default() -> Self {
|
|
Self(PhantomData)
|
|
}
|
|
}
|
|
|
|
impl<M> Codec<M> for JsonCodec<M>
|
|
where
|
|
M: Serialize + DeserializeOwned + Clone + Send + Sync + 'static,
|
|
{
|
|
fn encode(&self, msg: &M) -> Result<Vec<u8>, Error> {
|
|
serde_json::to_vec(msg).map_err(|e| Error::from(format!("encode: {e}")))
|
|
}
|
|
|
|
fn decode(&self, bytes: &[u8]) -> Result<M, Error> {
|
|
serde_json::from_slice(bytes).map_err(|e| Error::from(format!("decode: {e}")))
|
|
}
|
|
}
|