Download this file
| 1 | use std::io::{Read, Write}; |
| 2 | use yrs::{Doc, Options}; |
| 3 | fn main() { |
| 4 | let mut base = Vec::new(); |
| 5 | std::io::stdin().read_to_end(&mut base).unwrap(); |
| 6 | let doc = Doc::with_options(Options::with_guid_and_client_id( |
| 7 | "edit-wire".into(), |
| 8 | u32::MAX as u64, |
| 9 | )); |
| 10 | docs_core::apply_update(&doc, &base).unwrap(); |
| 11 | let text = "Edited <script> đŸ˜€"; |
| 12 | let mut input = Vec::new(); |
| 13 | for n in [1u32, 1, 1, 1] { |
| 14 | input.extend(n.to_be_bytes()); |
| 15 | } |
| 16 | input.push(2); |
| 17 | input.extend((text.len() as u32).to_be_bytes()); |
| 18 | input.extend(text.as_bytes()); |
| 19 | std::io::stdout() |
| 20 | .write_all(&docs_core::edit::edit(&doc, &input).unwrap()) |
| 21 | .unwrap(); |
| 22 | } |
| 23 | |