11use crate :: {
2- Asset , Assets , Bbox , Error , Fields , Href , Item , ItemAsset , Link , Links , Migrate , Result ,
3- Version , STAC_VERSION ,
2+ Asset , Assets , Bbox , Error , Href , Item , ItemAsset , Link , Links , Migrate , Result , Version ,
3+ STAC_VERSION ,
44} ;
55use chrono:: { DateTime , Utc } ;
66use serde:: { Deserialize , Serialize } ;
77use serde_json:: { Map , Value } ;
8+ use stac_derive:: { Fields , Href , Links } ;
89use std:: collections:: HashMap ;
910
1011const DEFAULT_LICENSE : & str = "proprietary" ;
@@ -21,7 +22,7 @@ const DEFAULT_LICENSE: &str = "proprietary";
2122/// A STAC `Collection` is represented in JSON format. Any JSON object that
2223/// contains all the required fields is a valid STAC `Collection` and also a valid
2324/// STAC `Catalog`.
24- #[ derive( Debug , Serialize , Deserialize , PartialEq , Clone ) ]
25+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Clone , Href , Links , Fields ) ]
2526#[ serde( tag = "type" ) ]
2627pub struct Collection {
2728 /// The STAC version the `Collection` implements.
@@ -288,29 +289,6 @@ impl Collection {
288289 }
289290}
290291
291- impl Href for Collection {
292- fn href ( & self ) -> Option < & str > {
293- self . href . as_deref ( )
294- }
295-
296- fn set_href ( & mut self , href : impl ToString ) {
297- self . href = Some ( href. to_string ( ) )
298- }
299-
300- fn clear_href ( & mut self ) {
301- self . href = None ;
302- }
303- }
304-
305- impl Links for Collection {
306- fn links ( & self ) -> & [ Link ] {
307- & self . links
308- }
309- fn links_mut ( & mut self ) -> & mut Vec < Link > {
310- & mut self . links
311- }
312- }
313-
314292impl Provider {
315293 /// Creates a new provider with the given name.
316294 ///
@@ -386,15 +364,6 @@ impl Assets for Collection {
386364 }
387365}
388366
389- impl Fields for Collection {
390- fn fields ( & self ) -> & Map < String , Value > {
391- & self . additional_fields
392- }
393- fn fields_mut ( & mut self ) -> & mut Map < String , Value > {
394- & mut self . additional_fields
395- }
396- }
397-
398367impl TryFrom < Collection > for Map < String , Value > {
399368 type Error = Error ;
400369 fn try_from ( collection : Collection ) -> Result < Self > {
0 commit comments