#[non_exhaustive]pub struct ObjectRef<K: Lookup + ?Sized> {
pub dyntype: K::DynamicType,
pub name: String,
pub namespace: Option<String>,
pub extra: Extra,
}
Expand description
A typed and namedspaced (if relevant) reference to a Kubernetes object
K
may be either the object type or DynamicObject
, in which case the
type is stored at runtime. Erased ObjectRef
s pointing to different types
are still considered different.
use kube_runtime::reflector::ObjectRef;
use k8s_openapi::api::core::v1::{ConfigMap, Secret};
assert_ne!(
ObjectRef::<ConfigMap>::new("a").erase(),
ObjectRef::<Secret>::new("a").erase(),
);
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.dyntype: K::DynamicType
§name: String
The name of the object
namespace: Option<String>
The namespace of the object
May only be None
if the kind is cluster-scoped (not located in a namespace).
Note that it is acceptable for an ObjectRef
to a cluster-scoped resource to
have a namespace. These are, however, not considered equal:
assert_ne!(ObjectRef::<ConfigMap>::new("foo"), ObjectRef::new("foo").within("bar"));
extra: Extra
Extra information about the object being referred to
This is not considered when comparing objects, but may be used when converting to and from other representations,
such as OwnerReference
or ObjectReference
.
Implementations§
source§impl<K: Lookup> ObjectRef<K>
impl<K: Lookup> ObjectRef<K>
pub fn new_with(name: &str, dyntype: K::DynamicType) -> Self
pub fn within(self, namespace: &str) -> Self
sourcepub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Selfwhere
K: Lookup,
pub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Selfwhere
K: Lookup,
Creates ObjectRef
from the resource and dynamic type.
sourcepub fn from_owner_ref(
namespace: Option<&str>,
owner: &OwnerReference,
dyntype: K::DynamicType,
) -> Option<Self>
pub fn from_owner_ref( namespace: Option<&str>, owner: &OwnerReference, dyntype: K::DynamicType, ) -> Option<Self>
Create an ObjectRef
from an OwnerReference
Returns None
if the types do not match.
sourcepub fn into_kind_unchecked<K2: Lookup>(
self,
dt2: K2::DynamicType,
) -> ObjectRef<K2>
pub fn into_kind_unchecked<K2: Lookup>( self, dt2: K2::DynamicType, ) -> ObjectRef<K2>
Convert into a reference to K2
Note that no checking is done on whether this conversion makes sense. For example, every Service
has a corresponding Endpoints
, but it wouldn’t make sense to convert a Pod
into a Deployment
.
pub fn erase(self) -> ObjectRef<DynamicObject>
Trait Implementations§
impl<K: Lookup + ?Sized> Eq for ObjectRef<K>where
K::DynamicType: Eq,
Auto Trait Implementations§
impl<K> Freeze for ObjectRef<K>
impl<K> RefUnwindSafe for ObjectRef<K>
impl<K> Send for ObjectRef<K>
impl<K> Sync for ObjectRef<K>
impl<K> Unpin for ObjectRef<K>
impl<K> UnwindSafe for ObjectRef<K>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more