events: reorder types in image module
This commit is contained in:
parent
8673d0d3f6
commit
826c379e80
@ -76,24 +76,49 @@ impl ImageEventContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about a thumbnail file content.
|
/// Image content.
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct ThumbnailFileContentInfo {
|
pub struct ImageContent {
|
||||||
/// The mimetype of the thumbnail, e.g. `image/png`.
|
/// The height of the image in pixels.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub mimetype: Option<String>,
|
pub height: Option<UInt>,
|
||||||
|
|
||||||
/// The size of the thumbnail in bytes.
|
/// The width of the image in pixels.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub size: Option<UInt>,
|
pub width: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ThumbnailFileContentInfo {
|
impl ImageContent {
|
||||||
/// Creates an empty `ThumbnailFileContentInfo`.
|
/// Creates a new empty `ImageContent`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new `ImageContent` with the given width and height.
|
||||||
|
pub fn with_size(width: UInt, height: UInt) -> Self {
|
||||||
|
Self { height: Some(height), width: Some(width) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Thumbnail content.
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
|
pub struct ThumbnailContent {
|
||||||
|
/// The file info of the thumbnail.
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub file: ThumbnailFileContent,
|
||||||
|
|
||||||
|
/// The image info of the thumbnail.
|
||||||
|
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub image: Option<Box<ImageContent>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ThumbnailContent {
|
||||||
|
/// Creates a `ThumbnailContent` with the given file and image info.
|
||||||
|
pub fn new(file: ThumbnailFileContent, image: Option<Box<ImageContent>>) -> Self {
|
||||||
|
Self { file, image }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Thumbnail file content.
|
/// Thumbnail file content.
|
||||||
@ -136,47 +161,22 @@ impl ThumbnailFileContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Thumbnail content.
|
/// Information about a thumbnail file content.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct ThumbnailContent {
|
pub struct ThumbnailFileContentInfo {
|
||||||
/// The file info of the thumbnail.
|
/// The mimetype of the thumbnail, e.g. `image/png`.
|
||||||
#[serde(flatten)]
|
|
||||||
pub file: ThumbnailFileContent,
|
|
||||||
|
|
||||||
/// The image info of the thumbnail.
|
|
||||||
#[serde(flatten, skip_serializing_if = "Option::is_none")]
|
|
||||||
pub image: Option<Box<ImageContent>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ThumbnailContent {
|
|
||||||
/// Creates a `ThumbnailContent` with the given file and image info.
|
|
||||||
pub fn new(file: ThumbnailFileContent, image: Option<Box<ImageContent>>) -> Self {
|
|
||||||
Self { file, image }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Image content.
|
|
||||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
|
||||||
pub struct ImageContent {
|
|
||||||
/// The height of the image in pixels.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub height: Option<UInt>,
|
pub mimetype: Option<String>,
|
||||||
|
|
||||||
/// The width of the image in pixels.
|
/// The size of the thumbnail in bytes.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub width: Option<UInt>,
|
pub size: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImageContent {
|
impl ThumbnailFileContentInfo {
|
||||||
/// Creates a new empty `ImageContent`.
|
/// Creates an empty `ThumbnailFileContentInfo`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
Self::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `ImageContent` with the given width and height.
|
|
||||||
pub fn with_size(width: UInt, height: UInt) -> Self {
|
|
||||||
Self { height: Some(height), width: Some(width) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user