Struct kube_runtime::reflector::ObjectRef[][src]

pub struct ObjectRef<K: Resource> {
    pub name: String,
    pub namespace: Option<String>,
    // some fields omitted
}
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

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"));

Implementations

Creates ObjectRef from the resource and dynamic type. Panics if name is missing (name always exists if the object was returned from the apiserver)

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

Performs the conversion.

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 !=.

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.

Performs the conversion.

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

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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