k8s_openapi/v1_29/api/core/v1/
local_volume_source.rs#[derive(Clone, Debug, Default, PartialEq)]
pub struct LocalVolumeSource {
pub fs_type: Option<String>,
pub path: String,
}
impl crate::DeepMerge for LocalVolumeSource {
fn merge_from(&mut self, other: Self) {
crate::DeepMerge::merge_from(&mut self.fs_type, other.fs_type);
crate::DeepMerge::merge_from(&mut self.path, other.path);
}
}
impl<'de> crate::serde::Deserialize<'de> for LocalVolumeSource {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
enum Field {
Key_fs_type,
Key_path,
Other,
}
impl<'de> crate::serde::Deserialize<'de> for Field {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
struct Visitor;
impl<'de> crate::serde::de::Visitor<'de> for Visitor {
type Value = Field;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("field identifier")
}
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
Ok(match v {
"fsType" => Field::Key_fs_type,
"path" => Field::Key_path,
_ => Field::Other,
})
}
}
deserializer.deserialize_identifier(Visitor)
}
}
struct Visitor;
impl<'de> crate::serde::de::Visitor<'de> for Visitor {
type Value = LocalVolumeSource;
fn expecting(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("LocalVolumeSource")
}
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
let mut value_fs_type: Option<String> = None;
let mut value_path: Option<String> = None;
while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
match key {
Field::Key_fs_type => value_fs_type = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Key_path => value_path = crate::serde::de::MapAccess::next_value(&mut map)?,
Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
}
}
Ok(LocalVolumeSource {
fs_type: value_fs_type,
path: value_path.unwrap_or_default(),
})
}
}
deserializer.deserialize_struct(
"LocalVolumeSource",
&[
"fsType",
"path",
],
Visitor,
)
}
}
impl crate::serde::Serialize for LocalVolumeSource {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
let mut state = serializer.serialize_struct(
"LocalVolumeSource",
1 +
self.fs_type.as_ref().map_or(0, |_| 1),
)?;
if let Some(value) = &self.fs_type {
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "fsType", value)?;
}
crate::serde::ser::SerializeStruct::serialize_field(&mut state, "path", &self.path)?;
crate::serde::ser::SerializeStruct::end(state)
}
}
#[cfg(feature = "schemars")]
impl crate::schemars::JsonSchema for LocalVolumeSource {
fn schema_name() -> String {
"io.k8s.api.core.v1.LocalVolumeSource".to_owned()
}
fn json_schema(__gen: &mut crate::schemars::gen::SchemaGenerator) -> crate::schemars::schema::Schema {
crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
metadata: Some(Box::new(crate::schemars::schema::Metadata {
description: Some("Local represents directly-attached storage with node affinity (Beta feature)".to_owned()),
..Default::default()
})),
instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::Object))),
object: Some(Box::new(crate::schemars::schema::ObjectValidation {
properties: [
(
"fsType".to_owned(),
crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
metadata: Some(Box::new(crate::schemars::schema::Metadata {
description: Some("fsType is the filesystem type to mount. It applies only when the Path is a block device. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". The default value is to auto-select a filesystem if unspecified.".to_owned()),
..Default::default()
})),
instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
..Default::default()
}),
),
(
"path".to_owned(),
crate::schemars::schema::Schema::Object(crate::schemars::schema::SchemaObject {
metadata: Some(Box::new(crate::schemars::schema::Metadata {
description: Some("path of the full path to the volume on the node. It can be either a directory or block device (disk, partition, ...).".to_owned()),
..Default::default()
})),
instance_type: Some(crate::schemars::schema::SingleOrVec::Single(Box::new(crate::schemars::schema::InstanceType::String))),
..Default::default()
}),
),
].into(),
required: [
"path".to_owned(),
].into(),
..Default::default()
})),
..Default::default()
})
}
}