(path: &std::path::Path)
| 137 | } |
| 138 | |
| 139 | pub fn from_path(path: &std::path::Path) -> anyhow::Result<Self> { |
| 140 | let buf = |
| 141 | std::fs::read(path).with_context(|| format!("error reading: {}", path.display()))?; |
| 142 | |
| 143 | // Try parsing using the latest format. |
| 144 | if let Some(data) = Self::from_bytes(&buf) { |
| 145 | return Ok(data); |
| 146 | } |
| 147 | // Fallback to legacy format. |
| 148 | legacy::multi_stream_from_bytes_v0(&buf).ok_or_else(|| { |
| 149 | anyhow::format_err!("error parsing {} as multistream data", path.display()) |
| 150 | }) |
| 151 | } |
| 152 | |
| 153 | pub fn to_bytes(&self) -> Vec<u8> { |
| 154 | let mut headers: Vec<_> = self |
nothing calls this directly
no test coverage detected