#[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 ObjectRefs 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: StringThe 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: ExtraExtra 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§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<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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.