Trait kube::core::ResourceExt

source ·
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§


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.


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.


fn namespace(&self) -> Option<String>

The namespace the resource is in


fn resource_version(&self) -> Option<String>

The resource version


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)


fn creation_timestamp(&self) -> Option<Time>

Returns the creation timestamp

This is guaranteed to exist on resources received by the apiserver.


fn labels(&self) -> &BTreeMap<String, String>

Returns resource labels


fn labels_mut(&mut self) -> &mut BTreeMap<String, String>

Provides mutable access to the labels


fn annotations(&self) -> &BTreeMap<String, String>

Returns resource annotations


fn annotations_mut(&mut self) -> &mut BTreeMap<String, String>

Provider mutable access to the annotations


fn owner_references(&self) -> &[OwnerReference]

Returns resource owner references


fn owner_references_mut(&mut self) -> &mut Vec<OwnerReference>

Provides mutable access to the owner references


fn finalizers(&self) -> &[String]

Returns resource finalizers


fn finalizers_mut(&mut self) -> &mut Vec<String>

Provides mutable access to the finalizers


fn managed_fields(&self) -> &[ManagedFieldsEntry]

Returns managed fields


fn managed_fields_mut(&mut self) -> &mut Vec<ManagedFieldsEntry>

Provides mutable access to managed fields

Object Safety§

This trait is not object safe.



impl<K> ResourceExt for Kwhere K: Resource,