isbnlib/enums/
string_or_key_value_block.rs

1use serde::{Deserialize, Serialize};
2
3use crate::jsonb::key_value_block::KeyValueBlock;
4
5#[derive(
6Serialize,
7Deserialize,
8Debug,
9Clone,
10PartialEq,
11)]
12#[serde(untagged)]
13pub enum StringOrKeyValueBlock {
14    String(String),
15    KeyValueBlock(KeyValueBlock)
16}
17
18impl StringOrKeyValueBlock {
19    pub fn to_string(self) -> String {
20        match self {
21            StringOrKeyValueBlock::String(string) => string,
22            StringOrKeyValueBlock::KeyValueBlock(block) => block.key
23        }
24    }
25}