Skip to main content

rustfs_targets/
domain.rs

1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::target::TargetType;
16use serde::{Deserialize, Serialize};
17
18/// Logical target domains supported by RustFS target plugins.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
20#[serde(rename_all = "snake_case")]
21pub enum TargetDomain {
22    Notify,
23    Audit,
24}
25
26impl TargetDomain {
27    #[inline]
28    pub fn runtime_target_type(self) -> TargetType {
29        match self {
30            TargetDomain::Notify => TargetType::NotifyEvent,
31            TargetDomain::Audit => TargetType::AuditLog,
32        }
33    }
34}
35
36impl From<TargetType> for TargetDomain {
37    fn from(value: TargetType) -> Self {
38        match value {
39            TargetType::NotifyEvent => TargetDomain::Notify,
40            TargetType::AuditLog => TargetDomain::Audit,
41        }
42    }
43}