Utility functions for jnovel module
This commit is contained in:
parent
d32e1001a1
commit
da9505cd61
1 changed files with 22 additions and 2 deletions
|
@ -74,8 +74,8 @@ pub(crate) struct ChapterDetail {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct LemmyPostInfo {
|
pub(crate) struct LemmyPostInfo {
|
||||||
title: String,
|
pub(crate) title: String,
|
||||||
url: Url,
|
pub(crate) url: Url,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
@ -102,6 +102,10 @@ impl PartInfo {
|
||||||
NoParts => 0,
|
NoParts => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn as_string(&self) -> String {
|
||||||
|
self.as_u8().to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for PartInfo {
|
impl PartialEq for PartInfo {
|
||||||
|
@ -148,6 +152,22 @@ pub(crate) enum PostInfo {
|
||||||
Volume { part: PartInfo, lemmy_info: LemmyPostInfo },
|
Volume { part: PartInfo, lemmy_info: LemmyPostInfo },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PostInfo {
|
||||||
|
pub(crate) fn get_part_info(&self) -> PartInfo {
|
||||||
|
match self {
|
||||||
|
Chapter {part: part_info, ..} => *part_info,
|
||||||
|
Volume {part: part_info, ..} => *part_info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_lemmy_info(&self) -> LemmyPostInfo {
|
||||||
|
match self {
|
||||||
|
Chapter {lemmy_info: lemmy_info, ..} => lemmy_info.clone(),
|
||||||
|
Volume {lemmy_info: lemmy_info, ..} => lemmy_info.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl PartialEq for PostInfo {
|
impl PartialEq for PostInfo {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
let self_part = match self {
|
let self_part = match self {
|
||||||
|
|
Loading…
Reference in a new issue