1 // Copyright 2020 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /// An enum to express the kind of the backend of `Executor` 6 #[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Deserialize, serde_keyvalue::FromKeyValues)] 7 #[serde(deny_unknown_fields, rename_all = "kebab-case")] 8 pub enum ExecutorKindSys { 9 Handle, 10 Overlapped { concurrency: Option<u32> }, 11 } 12 13 impl serde::Serialize for ExecutorKindSys { serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer,14 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 15 where 16 S: serde::Serializer, 17 { 18 serializer.serialize_str(&match self { 19 ExecutorKindSys::Handle => "handle".to_string(), 20 ExecutorKindSys::Overlapped { concurrency: None } => "overlapped".to_string(), 21 ExecutorKindSys::Overlapped { 22 concurrency: Some(n), 23 } => format!("overlapped,concurrency={}", n), 24 }) 25 } 26 } 27