Struct kube_runtime::reflector::ObjectRef
source · [−]#[non_exhaustive]pub struct ObjectRef<K: Resource> {
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
sourceimpl<K: Resource> ObjectRef<K>
impl<K: Resource> 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) -> Self where
K: Resource,
pub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Self where
K: Resource,
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: Resource>(
self,
dt2: K2::DynamicType
) -> ObjectRef<K2>
pub fn into_kind_unchecked<K2: Resource>(
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
sourceimpl<K: Resource> From<ObjectRef<K>> for ReconcileRequest<K>
impl<K: Resource> From<ObjectRef<K>> for ReconcileRequest<K>
sourceimpl<K: Resource> From<ObjectRef<K>> for ObjectReference
impl<K: Resource> From<ObjectRef<K>> for ObjectReference
impl<K: Resource> Eq for ObjectRef<K> where
K::DynamicType: Eq,
Auto Trait Implementations
impl<K> RefUnwindSafe for ObjectRef<K> where
<K as Resource>::DynamicType: RefUnwindSafe,
impl<K> Send for ObjectRef<K>
impl<K> Sync for ObjectRef<K>
impl<K> Unpin for ObjectRef<K> where
<K as Resource>::DynamicType: Unpin,
impl<K> UnwindSafe for ObjectRef<K> where
<K as Resource>::DynamicType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more