Saving Yjs docs to files using Yrs

I’m trying to save a Yjs doc to a file and want to know if I’m doing this correctly. I’m using Yrs and was thinking to use “encodeStateAsUpdate” with an empty StateVector to store the doc as a list of u8s in a file.

    let doc = Doc::new();
    let text = doc.get_or_insert_text("test");
        let mut txn = doc.transact_mut();
        text.push(&mut txn, "hello world");

    let encoded_doc = doc

    let new_doc = Doc::new();
        let mut txn = new_doc.transact_mut();
        let update = Update::decode_v1(&encoded_doc).unwrap();
    println!("New doc: {:?}", new_doc);

The output of this is

Doc { store: StoreRef(AtomicRefCell { value: 2249705684 { root types: {"test": YText(start: (<2249705684#0>))}, blocks:  { 2249705684: [Item(<2249705684#0>, len: 11, parent: <root>: 'hello world')] } } }) }

New doc: Doc { store: StoreRef(AtomicRefCell { value: 3235410531 { root types: {"test": UnknownRef(start: (<2249705684#0>))}, blocks:  { 2249705684: [Item(<2249705684#0>, len: 11, parent: <root>: 'hello world')] } } }) }

As you can see, the doc that is loaded from the encoded doc has a different type with “UnknownRef”

What is the correct way for me to do this?