use super::types::FnfChart;
use crate::error::{RoxError, RoxResult};
const MAX_FILE_SIZE: usize = 100 * 1024 * 1024;
pub fn parse(data: &[u8]) -> RoxResult<FnfChart> {
if data.len() > MAX_FILE_SIZE {
return Err(RoxError::InvalidFormat(format!(
"File too large: {} bytes (max {}MB)",
data.len(),
MAX_FILE_SIZE / 1024 / 1024
)));
}
let content = std::str::from_utf8(data)
.map_err(|e| RoxError::InvalidFormat(format!("Invalid UTF-8: {e}")))?;
serde_json::from_str(content).map_err(|e| RoxError::InvalidFormat(format!("Invalid JSON: {e}")))
}