voxj-codec 0.1.1

Encodes voxj types into .voxj / .voxjz documents.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use crate::{Result, from_voxj_file_bytes, from_voxjz_file_bytes};
use voxj::VoxjSerdeFile;

/// Decodes either a `.voxj` (JSON, leading `{`) or `.voxjz` (zip, leading `PK`)
/// document, detecting the container by its leading bytes.
pub fn from_voxj_or_voxjz_file_bytes(bytes: &[u8]) -> Result<VoxjSerdeFile> {
    if bytes.starts_with(b"PK") {
        from_voxjz_file_bytes(bytes)
    } else {
        from_voxj_file_bytes(bytes)
    }
}