pub fn encode_portable(codec: CodecId, expr: &Expr) -> Result<String>Expand description
Serialize a data-subset Expr into the codec-neutral portable text form.
codec is used only to tag any error with the calling codec’s id.
§Examples
use sim_codec::{decode_portable, encode_portable};
use sim_kernel::{CodecId, Expr};
let expr = Expr::List(vec![Expr::Nil, Expr::Bool(true), Expr::String("hi".into())]);
let text = encode_portable(CodecId(0), &expr).unwrap();
assert_eq!(decode_portable(CodecId(0), &text).unwrap(), expr);
// Eval-only forms are not data and fail closed.
assert!(encode_portable(CodecId(0), &Expr::Block(vec![])).is_err());