use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Datastore {
Running,
Candidate,
Startup,
}
impl Datastore {
pub fn as_xml_tag(&self) -> &'static str {
match self {
Datastore::Running => "running",
Datastore::Candidate => "candidate",
Datastore::Startup => "startup",
}
}
}
impl fmt::Display for Datastore {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_xml_tag())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DefaultOperation {
Merge,
Replace,
None,
}
impl DefaultOperation {
pub fn as_str(&self) -> &'static str {
match self {
DefaultOperation::Merge => "merge",
DefaultOperation::Replace => "replace",
DefaultOperation::None => "none",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TestOption {
TestThenSet,
Set,
TestOnly,
}
impl TestOption {
pub fn as_str(&self) -> &'static str {
match self {
TestOption::TestThenSet => "test-then-set",
TestOption::Set => "set",
TestOption::TestOnly => "test-only",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ErrorOption {
StopOnError,
ContinueOnError,
RollbackOnError,
}
impl ErrorOption {
pub fn as_str(&self) -> &'static str {
match self {
ErrorOption::StopOnError => "stop-on-error",
ErrorOption::ContinueOnError => "continue-on-error",
ErrorOption::RollbackOnError => "rollback-on-error",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OpenConfigurationMode {
Private,
Exclusive,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LoadAction {
Set,
Merge,
Replace,
Override,
Update,
}
impl LoadAction {
pub fn as_str(&self) -> &'static str {
match self {
LoadAction::Set => "set",
LoadAction::Merge => "merge",
LoadAction::Replace => "replace",
LoadAction::Override => "override",
LoadAction::Update => "update",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LoadFormat {
Text,
Xml,
}
impl LoadFormat {
pub fn as_str(&self) -> &'static str {
match self {
LoadFormat::Text => "text",
LoadFormat::Xml => "xml",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ErrorSeverity {
Error,
Warning,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RpcErrorType {
Transport,
Rpc,
Protocol,
Application,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ErrorTag {
InUse,
InvalidValue,
TooBig,
MissingAttribute,
BadAttribute,
UnknownAttribute,
MissingElement,
BadElement,
UnknownElement,
UnknownNamespace,
AccessDenied,
LockDenied,
ResourceDenied,
RollbackFailed,
DataExists,
DataMissing,
OperationNotSupported,
OperationFailed,
MalformedMessage,
Other(String),
}
impl ErrorTag {
#[allow(clippy::should_implement_trait)]
pub fn from_str(tag: &str) -> Self {
match tag {
"in-use" => ErrorTag::InUse,
"invalid-value" => ErrorTag::InvalidValue,
"too-big" => ErrorTag::TooBig,
"missing-attribute" => ErrorTag::MissingAttribute,
"bad-attribute" => ErrorTag::BadAttribute,
"unknown-attribute" => ErrorTag::UnknownAttribute,
"missing-element" => ErrorTag::MissingElement,
"bad-element" => ErrorTag::BadElement,
"unknown-element" => ErrorTag::UnknownElement,
"unknown-namespace" => ErrorTag::UnknownNamespace,
"access-denied" => ErrorTag::AccessDenied,
"lock-denied" => ErrorTag::LockDenied,
"resource-denied" => ErrorTag::ResourceDenied,
"rollback-failed" => ErrorTag::RollbackFailed,
"data-exists" => ErrorTag::DataExists,
"data-missing" => ErrorTag::DataMissing,
"operation-not-supported" => ErrorTag::OperationNotSupported,
"operation-failed" => ErrorTag::OperationFailed,
"malformed-message" => ErrorTag::MalformedMessage,
other => ErrorTag::Other(other.to_string()),
}
}
}