isbnlib/enums/
bio_enum.rs1use crate::jsonb::block::Block;
2use serde::{Deserialize, Serialize};
3
4#[derive(
5 Serialize,
6 Deserialize,
7 Debug,
8 Clone,
9 PartialEq,
10)]
11#[serde(untagged)]
12pub enum Bio {
13 String(String),
14 Block(Block)
15}
16
17impl Bio {
18 pub fn to_string(self) -> String {
19 match self {
20 Bio::String(content) => content,
21 Bio::Block(content) => content.to_string()
22 }
23 }
24
25 pub fn to_string_opt(val: Option<Self>) -> Option<String> {
26 match val {
27 Some(content) => {
28 Some(<Bio as Clone>::clone(&content).to_string())
29
30 }
31 None => {
32 None
33 }
34 }
35 }
36}