1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
//! Types that represent the data structures of the `xcassets` format. use serde::Serialize; /// Represents the JSON-serialized data structure that is contained within a /// `xcassets` asset catalog. #[derive(Serialize)] pub struct XcAssets<'a> { /// Contains metadata about this asset catalog. pub info: Info<'a>, } /// Represents the JSON-serialized data structure that is contained within an /// image set in an asset catalog. #[derive(Serialize)] pub struct ImageSet<'a> { /// A set of alternative images for this image set. For example, multiple /// images can be provided to support different screen DPIs. pub images: Vec<Image<'a>>, /// Contains metadata about this image set. pub info: Info<'a>, } /// Metadata structure that is used in several places in an asset catalog. #[derive(Serialize)] pub struct Info<'a> { /// Contains the author of the corresponding data structure. This is usually /// Xcode. pub author: &'a str, /// Contains the version of the corresponding data structure. This is /// usually 1. pub version: usize, } /// Represents the JSON-serialized data structure that is contained within a /// folder in an asset catalog. #[derive(Serialize)] pub struct Folder<'a> { /// Properties of this folder. pub properties: Properties, /// Contains metadata about this folder. pub info: Info<'a>, } /// Additional properties of a folder. #[derive(Serialize)] pub struct Properties { /// Boolean that indicates whether this folder provides a namespace. If it /// provides a namespace, images are accessed through /// `UIImage(named: "folder-name/image-name")`. #[serde(rename = "provides-namespace")] pub provides_namespace: bool, } /// A single image within an image set. #[derive(Serialize)] pub struct Image<'a> { /// Original file name of the image. #[serde(skip_serializing_if = "Option::is_none")] pub filename: Option<&'a str>, /// Contains the device idiom for which this image should be used. For /// example, this can be used to distinguish between iPhone and iPad. pub idiom: &'a str, /// Relative screen DPI for which this image should be used. For example, /// this can be used to provide both @1x and @2x (or even @3x) /// rasterizations of the same source image. pub scale: &'a str, /// Size of this image. #[serde(skip_serializing_if = "Option::is_none")] pub size: Option<&'a str>, }