pub trait ResourceExt: Resource {
Show 16 methods
// Required methods
fn name_unchecked(&self) -> String;
fn name_any(&self) -> String;
fn namespace(&self) -> Option<String>;
fn resource_version(&self) -> Option<String>;
fn uid(&self) -> Option<String>;
fn creation_timestamp(&self) -> Option<Time>;
fn labels(&self) -> &BTreeMap<String, String>;
fn labels_mut(&mut self) -> &mut BTreeMap<String, String>;
fn annotations(&self) -> &BTreeMap<String, String>;
fn annotations_mut(&mut self) -> &mut BTreeMap<String, String>;
fn owner_references(&self) -> &[OwnerReference];
fn owner_references_mut(&mut self) -> &mut Vec<OwnerReference>;
fn finalizers(&self) -> &[String];
fn finalizers_mut(&mut self) -> &mut Vec<String>;
fn managed_fields(&self) -> &[ManagedFieldsEntry];
fn managed_fields_mut(&mut self) -> &mut Vec<ManagedFieldsEntry>;
}
Expand description
Helper methods for resources.
Required Methods§
Sourcefn name_unchecked(&self) -> String
fn name_unchecked(&self) -> String
Returns the name of the resource, panicking if it is unset
Only use this function if you know that name is set; for example when the resource was received from the apiserver (post-admission), or if you constructed the resource with the name.
At admission, .metadata.generateName
can be set instead of name
and in those cases this function can panic.
Prefer using .meta().name
or name_any
for the more general cases.
Sourcefn name_any(&self) -> String
fn name_any(&self) -> String
Returns the most useful name identifier available
This is tries name
, then generateName
, and falls back on an empty string when neither is set.
Generally you always have one of the two unless you are creating the object locally.
This is intended to provide something quick and simple for standard logging purposes.
For more precise use cases, prefer doing your own defaulting.
For true uniqueness, prefer uid
.
Sourcefn resource_version(&self) -> Option<String>
fn resource_version(&self) -> Option<String>
The resource version
Sourcefn uid(&self) -> Option<String>
fn uid(&self) -> Option<String>
Unique ID (if you delete resource and then create a new resource with the same name, it will have different ID)
Sourcefn creation_timestamp(&self) -> Option<Time>
fn creation_timestamp(&self) -> Option<Time>
Returns the creation timestamp
This is guaranteed to exist on resources received by the apiserver.
Sourcefn labels_mut(&mut self) -> &mut BTreeMap<String, String>
fn labels_mut(&mut self) -> &mut BTreeMap<String, String>
Provides mutable access to the labels
Sourcefn annotations(&self) -> &BTreeMap<String, String>
fn annotations(&self) -> &BTreeMap<String, String>
Returns resource annotations
Sourcefn annotations_mut(&mut self) -> &mut BTreeMap<String, String>
fn annotations_mut(&mut self) -> &mut BTreeMap<String, String>
Provider mutable access to the annotations
Sourcefn owner_references(&self) -> &[OwnerReference]
fn owner_references(&self) -> &[OwnerReference]
Returns resource owner references
Sourcefn owner_references_mut(&mut self) -> &mut Vec<OwnerReference>
fn owner_references_mut(&mut self) -> &mut Vec<OwnerReference>
Provides mutable access to the owner references
Sourcefn finalizers(&self) -> &[String]
fn finalizers(&self) -> &[String]
Returns resource finalizers
Sourcefn finalizers_mut(&mut self) -> &mut Vec<String>
fn finalizers_mut(&mut self) -> &mut Vec<String>
Provides mutable access to the finalizers
Sourcefn managed_fields(&self) -> &[ManagedFieldsEntry]
fn managed_fields(&self) -> &[ManagedFieldsEntry]
Returns managed fields
Sourcefn managed_fields_mut(&mut self) -> &mut Vec<ManagedFieldsEntry>
fn managed_fields_mut(&mut self) -> &mut Vec<ManagedFieldsEntry>
Provides mutable access to managed fields
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.