|
| 1 | +use serde::{Deserialize, Serialize}; |
| 2 | +use serde_json::{Map, Value}; |
| 3 | + |
| 4 | +/// An item asset is an object that contains details about the datafiles that |
| 5 | +/// will be included in member items. |
| 6 | +/// |
| 7 | +/// Assets included at the Collection level do not imply that all assets are |
| 8 | +/// available from all Items. However, it is recommended that the Asset |
| 9 | +/// Definition is a complete set of all assets that may be available from any |
| 10 | +/// member Items. So this should be the union of the available assets, not just |
| 11 | +/// the intersection of the available assets. |
| 12 | +/// |
| 13 | +/// Other custom fields, or fields from other extensions may also be included in the Asset object. |
| 14 | +/// |
| 15 | +/// Any property that exists for a Collection-level asset object must also exist |
| 16 | +/// in the corresponding assets object in each Item. If a collection's asset |
| 17 | +/// object contains properties that are not explicitly stated in the Item's |
| 18 | +/// asset object then that property does not apply to the item's asset. Item |
| 19 | +/// asset objects at the Collection-level can describe any of the properties of |
| 20 | +/// an asset, but those assets properties and values must also reside in the |
| 21 | +/// item's asset object. To consolidate item-level asset object properties in an |
| 22 | +/// API setting, consider storing the STAC Item objects without the larger |
| 23 | +/// properties internally as 'invalid' STAC items, and merge in the desired |
| 24 | +/// properties at serving time from the Collection-level. |
| 25 | +/// |
| 26 | +/// At least two fields (e.g. title and type) are required to be provided, in |
| 27 | +/// order for it to adequately describe Item assets. The two fields must not |
| 28 | +/// necessarily be taken from the defined fields on this struct and may include |
| 29 | +/// any custom field. |
| 30 | +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] |
| 31 | +pub struct ItemAsset { |
| 32 | + /// The displayed title for clients and users. |
| 33 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 34 | + pub title: Option<String>, |
| 35 | + |
| 36 | + /// A description of the Asset providing additional details, such as how it |
| 37 | + /// was processed or created. |
| 38 | + /// |
| 39 | + /// CommonMark 0.29 syntax MAY be used for rich text representation. |
| 40 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 41 | + pub description: Option<String>, |
| 42 | + |
| 43 | + /// Media type of the asset. |
| 44 | + #[serde(skip_serializing_if = "Option::is_none")] |
| 45 | + pub r#type: Option<String>, |
| 46 | + |
| 47 | + /// The semantic roles of the asset, similar to the use of rel in links. |
| 48 | + #[serde(skip_serializing_if = "Vec::is_empty", default)] |
| 49 | + pub roles: Vec<String>, |
| 50 | + |
| 51 | + /// Additional fields. |
| 52 | + #[serde(flatten)] |
| 53 | + pub additional_fields: Map<String, Value>, |
| 54 | +} |
0 commit comments