postscript/compact1/index/
names.rs1use crate::compact1::index::Index;
2use crate::{Error, Result};
3
4index! {
5 pub Names
7}
8
9impl TryFrom<Names> for Vec<String> {
10 type Error = Error;
11
12 fn try_from(names: Names) -> Result<Self> {
13 let Names(Index { data, .. }) = names;
14 let mut vector = Vec::with_capacity(data.len());
15 for chunk in data {
16 vector.push(match String::from_utf8(chunk) {
17 Ok(string) => string,
18 Err(chunk) => String::from_utf8_lossy(&chunk.into_bytes()).into_owned(),
19 });
20 }
21 Ok(vector)
22 }
23}