etptypes/energistics/etp/v12/datatypes/object/
context_scope_kind.rs1#![allow(unused_imports)]
4#![allow(non_camel_case_types)]
5use crate::helpers::*;
6use apache_avro::{Error, Schema};
7use bytes;
8use derivative::Derivative;
9use std::collections::HashMap;
10use std::time::SystemTime;
11
12use crate::helpers::Schemable;
13use apache_avro::{from_avro_datum, from_value, AvroResult};
14use std::fmt;
15use std::io::Read;
16use std::slice::Iter;
17use std::str::FromStr;
18
19#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
20#[serde(rename_all = "PascalCase")]
21pub enum ContextScopeKind {
22 #[serde(rename(serialize = "self", deserialize = "self"))]
24 Self_,
25 #[serde(rename(serialize = "sources", deserialize = "sources"))]
26 Sources,
27 #[serde(rename(serialize = "targets", deserialize = "targets"))]
28 Targets,
29 #[serde(rename(serialize = "sourcesOrSelf", deserialize = "sourcesOrSelf"))]
30 SourcesOrSelf,
31 #[serde(rename(serialize = "targetsOrSelf", deserialize = "targetsOrSelf"))]
32 TargetsOrSelf,
33}
34
35impl fmt::Display for ContextScopeKind {
36 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37 write!(
38 f,
39 "{}",
40 match self {
41 ContextScopeKind::Self_ => "self",
42 ContextScopeKind::Sources => "sources",
43 ContextScopeKind::Targets => "targets",
44 ContextScopeKind::SourcesOrSelf => "sourcesOrSelf",
45 ContextScopeKind::TargetsOrSelf => "targetsOrSelf",
46 }
47 )
48 }
49}
50
51impl FromStr for ContextScopeKind {
52 type Err = ();
53 fn from_str(input: &str) -> Result<ContextScopeKind, Self::Err> {
54 match input {
55 "self" => Ok(ContextScopeKind::Self_),
56 "sources" => Ok(ContextScopeKind::Sources),
57 "targets" => Ok(ContextScopeKind::Targets),
58 "sourcesOrSelf" => Ok(ContextScopeKind::SourcesOrSelf),
59 "targetsOrSelf" => Ok(ContextScopeKind::TargetsOrSelf),
60 _ => Err(()),
61 }
62 }
63}
64
65impl ContextScopeKind {
66 pub fn iter() -> Iter<'static, ContextScopeKind> {
67 static VEC_ENUM: [ContextScopeKind; 5] = [
68 ContextScopeKind::Self_,
69 ContextScopeKind::Sources,
70 ContextScopeKind::Targets,
71 ContextScopeKind::SourcesOrSelf,
72 ContextScopeKind::TargetsOrSelf,
73 ];
74 VEC_ENUM.iter()
75 }
76}