Crate serde_transcode[−][src]
Expand description
Transcode from one Serde format to another.
This crate provides functionality to “transcode” from an arbitrary Serde
Deserializer
to an arbitrary Serde Serializer
without needing to
collect the entire input into an intermediate form in memory. For example,
you could translate a stream of JSON data into a stream of CBOR data, or
translate JSON into its pretty-printed form.
Examples
Translate a JSON file to a pretty-printed version.
extern crate serde; extern crate serde_json; extern crate serde_transcode; use serde::Serialize; use serde_json::{Serializer, Deserializer}; use std::io::{Read, Write, BufReader, BufWriter}; use std::fs::File; fn main() { let reader = BufReader::new(File::open("input.json").unwrap()); let writer = BufWriter::new(File::create("output.json").unwrap()); let mut deserializer = Deserializer::from_reader(reader); let mut serializer = Serializer::pretty(writer); serde_transcode::transcode(&mut deserializer, &mut serializer).unwrap(); serializer.into_inner().flush().unwrap(); }
Structs
A Serde transcoder.
Functions
Transcodes from a Serde Deserializer
to a Serde Serializer
.