#[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 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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
dyntype: K::DynamicTypename: 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

Creates ObjectRef from the resource and dynamic type.

Create an ObjectRef from an OwnerReference

Returns None if the types do not match.

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.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more