#import "osor_serialization"; /** From my game: proto2 */ marshal :: inline (input: *$T) -> []u8 { return serialize(input); } unmarshal :: inline (bytes: []u8, $Output_Type: Type) -> *Output_Type { return deserialize(bytes, Output_Type); } marshal_and_save_to_disk :: (file_path: string, input: *$T) -> ok: bool { bytes := marshal(input); ok := write_entire_file(file_path, bytes.data, bytes.count); // TODO(adam, 5): Error reporter if !ok { log_error("Could not write file: %", file_path); return false; } return true; } read_from_disk_and_unmarshal :: (file_path: string, $Output_Type: Type) -> (ok: bool, output: *Output_Type) { bin, ok := read_entire_file(file_path, log_errors = true); if !ok return ok, null; return true, unmarshal(cast([]u8, bin), Output_Type); }