now workspaces for modular compilation (maybe faster)

This commit is contained in:
elvis
2025-09-12 16:34:58 +02:00
parent fa1127358d
commit e41d92ac36
44 changed files with 318 additions and 227 deletions

View File

@ -0,0 +1,43 @@
//! Definitions for serializing and deserializing graph and translator.
//!
//! N.B. after serialization the size of the graph may be much larger than
//! before since a lot of ```Rc``` are used in ```RSsystem```.
use std::io;
use serde::{Deserialize, Serialize};
use super::graph;
use super::translator::Translator;
#[derive(Serialize, Deserialize)]
struct GraphAndTranslator {
graph: graph::SystemGraph,
translator: Translator,
}
/// Serializer for graph and translator.
pub fn ser<W>(
writer: W,
graph: &graph::SystemGraph,
translator: &Translator,
) -> Result<(), serde_cbor_2::Error>
where
W: io::Write,
{
serde_cbor_2::to_writer(writer, &GraphAndTranslator {
graph: graph.clone(),
translator: translator.clone(),
})
}
/// Deserializer for file that contains graph and translator.
pub fn de<R>(
reader: R,
) -> Result<(graph::SystemGraph, Translator), serde_cbor_2::Error>
where
R: io::Read,
{
let gat: GraphAndTranslator = serde_cbor_2::from_reader(reader)?;
Ok((gat.graph, gat.translator))
}