pub trait MapNamespace {
    // Required method
    fn map_namespace<'a>(&self, path_parts: &[&'a str]) -> Option<Vec<&'a str>>;
}
Expand description

A mechanism for converting (the components of) an openapi path to (the components of) a Rust namespace.

The k8s-openapi code generator uses this trait to emit the paths of all types relative to the k8s_openapi crate. For example, it maps the components of the openapi path io.k8s.api.core.v1 to the components of the Rust namespace crate::core::v1. The io.k8s. prefix is stripped and the path starts with crate::.

Other code generators can have more complicated implementations. For example, an OpenShift code generator that has its own types but also wants to reuse types from the k8s-openapi crate would map com.github.openshift. to crate:: and io.k8s. to k8s_openapi:: instead.

The implementation should return None for paths that it does not recognize.

Required Methods§

source

fn map_namespace<'a>(&self, path_parts: &[&'a str]) -> Option<Vec<&'a str>>

Implementors§