isbnlib/jsonb/
authors_list_element.rs

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
use serde::{Deserialize, Serialize};
use crate::enums::author_list_element_type::AuthorListElementType;
use crate::enums::string_or_key_value_block::StringOrKeyValueBlock;

#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
)]
pub struct AuthorsListElement {
    #[serde(rename(deserialize = "type"))]
    pub value_type:  AuthorListElementType,
    pub author: Option<StringOrKeyValueBlock>
}

impl AuthorsListElement {
    pub fn to_string(self) -> String {
        match self.author {
            Some(author) => author.to_string(),
            None => String::new()
        }
    }
}