@@ -124,39 +124,19 @@ impl Container {
124
124
}
125
125
126
126
fn parse ( elem : & Element ) -> azure_core:: Result < Container > {
127
- let name = cast_must :: < String > ( elem, & [ "Name" ] ) . map_kind ( ErrorKind :: DataConversion ) ?;
128
- let last_modified = cast_must :: < DateTime < Utc > > ( elem, & [ "Properties" , "Last-Modified" ] )
129
- . map_kind ( ErrorKind :: DataConversion ) ?;
130
- let e_tag = cast_must :: < String > ( elem, & [ "Properties" , "Etag" ] )
131
- . map_kind ( ErrorKind :: DataConversion ) ?;
132
-
133
- let lease_state = cast_must :: < LeaseState > ( elem, & [ "Properties" , "LeaseState" ] )
134
- . map_kind ( ErrorKind :: DataConversion ) ?;
135
-
136
- let lease_duration = cast_optional :: < LeaseDuration > ( elem, & [ "Properties" , "LeaseDuration" ] )
137
- . map_kind ( ErrorKind :: DataConversion ) ?;
138
-
139
- let lease_status = cast_must :: < LeaseStatus > ( elem, & [ "Properties" , "LeaseStatus" ] )
140
- . map_kind ( ErrorKind :: DataConversion ) ?;
141
-
127
+ let name = cast_must ( elem, & [ "Name" ] ) . map_kind ( ErrorKind :: DataConversion ) ?;
128
+ let last_modified = cast_must ( elem, & [ "Properties" , "Last-Modified" ] ) ?;
129
+ let e_tag = cast_must ( elem, & [ "Properties" , "Etag" ] ) ?;
130
+ let lease_state = cast_must ( elem, & [ "Properties" , "LeaseState" ] ) ?;
131
+ let lease_duration = cast_optional ( elem, & [ "Properties" , "LeaseDuration" ] ) ?;
132
+ let lease_status = cast_must ( elem, & [ "Properties" , "LeaseStatus" ] ) ?;
142
133
let public_access =
143
- match cast_optional :: < PublicAccess > ( elem, & [ "Properties" , "PublicAccess" ] )
144
- . map_kind ( ErrorKind :: DataConversion ) ?
145
- {
146
- Some ( pa) => pa,
147
- None => PublicAccess :: None ,
148
- } ;
149
-
150
- let has_immutability_policy =
151
- cast_must :: < bool > ( elem, & [ "Properties" , "HasImmutabilityPolicy" ] )
152
- . map_kind ( ErrorKind :: DataConversion ) ?;
153
- let has_legal_hold = cast_must :: < bool > ( elem, & [ "Properties" , "HasLegalHold" ] )
154
- . map_kind ( ErrorKind :: DataConversion ) ?;
155
-
134
+ cast_optional ( elem, & [ "Properties" , "PublicAccess" ] ) ?. unwrap_or ( PublicAccess :: None ) ;
135
+ let has_immutability_policy = cast_must ( elem, & [ "Properties" , "HasImmutabilityPolicy" ] ) ?;
136
+ let has_legal_hold = cast_must ( elem, & [ "Properties" , "HasLegalHold" ] ) ?;
156
137
let metadata = {
157
138
let mut hm = HashMap :: new ( ) ;
158
- let metadata =
159
- traverse ( elem, & [ "Metadata" ] , true ) . map_kind ( ErrorKind :: DataConversion ) ?;
139
+ let metadata = traverse ( elem, & [ "Metadata" ] , true ) ?;
160
140
161
141
for m in metadata {
162
142
for key in & m. children {
@@ -170,18 +150,18 @@ impl Container {
170
150
}
171
151
} ;
172
152
173
- let key = elem. name . to_owned ( ) ;
174
-
175
153
if elem. children . is_empty ( ) {
176
154
return Err ( Error :: message (
177
155
ErrorKind :: DataConversion ,
178
156
"Metadata node should not be empty" ,
179
157
) ) ;
180
158
}
181
159
160
+ let key = elem. name . clone ( ) ;
161
+
182
162
let content = {
183
- match elem. children [ 0 ] {
184
- Xml :: CharacterNode ( ref content) => content. to_owned ( ) ,
163
+ match & elem. children [ 0 ] {
164
+ Xml :: CharacterNode ( content) => content. clone ( ) ,
185
165
_ => {
186
166
return Err ( Error :: message ( ErrorKind :: DataConversion ,
187
167
"Metadata node should contain a CharacterNode with metadata value" ,
0 commit comments