pub struct Record {
    pub platform_id: PlatformID,
    pub encoding_id: EncodingID,
    pub language_id: LanguageID,
    pub name_id: NameID,
    pub length: u16,
    pub offset: u16,
}
Expand description

A record of a naming table.

Fields§

§platform_id: PlatformID§encoding_id: EncodingID§language_id: LanguageID§name_id: NameID§length: u16§offset: u16

Implementations§

Return the IETF-BCP-47 language.

Examples found in repository?
src/naming_table/mod.rs (line 115)
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    pub fn collect<T>(&self) -> T
    where
        T: FromIterator<((NameID, Option<String>), Option<String>)>,
    {
        let (records, language_tags, data) = match self {
            &NamingTable::Format0(ref table) => (&table.records, &[][..], &table.data),
            &NamingTable::Format1(ref table) => {
                (&table.records, &table.language_tags[..], &table.data)
            }
        };
        let language_tags: Vec<_> = language_tags
            .iter()
            .map(|record| {
                let (offset, length) = (record.offset as usize, record.length as usize);
                encoding::unicode::decode_utf16(&data[offset..(offset + length)])
            })
            .collect();
        records
            .iter()
            .map(|record| {
                let language_tag = record.language_tag(&language_tags);
                let (offset, length) = (record.offset as usize, record.length as usize);
                let value = decode(
                    record.platform_id,
                    record.encoding_id,
                    record.language_id,
                    language_tag.as_deref(),
                    &data[offset..(offset + length)],
                );
                ((record.name_id, language_tag), value)
            })
            .collect()
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Read a value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.