windows_metadata/reader/tables/
field.rs

1use super::*;
2
3impl std::fmt::Debug for Field<'_> {
4    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
5        f.debug_tuple("Field").field(&self.name()).finish()
6    }
7}
8
9impl Field<'_> {
10    pub fn flags(&self) -> FieldAttributes {
11        FieldAttributes(self.usize(0).try_into().unwrap())
12    }
13
14    pub fn name(&self) -> &str {
15        self.str(1)
16    }
17
18    pub fn ty(&self) -> Type {
19        let mut blob = self.blob(2);
20        let prolog = blob.read_u8();
21        debug_assert_eq!(prolog, 0x6);
22
23        blob.read_type_signature(&[])
24    }
25
26    pub fn constant(&self) -> Option<Constant> {
27        self.equal_range(1, HasConstant::Field(*self).encode())
28            .next()
29    }
30}