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

impl<K: Resource> ObjectRef<K> where
    K::DynamicType: Default
[src]

#[must_use]
pub fn new(name: &str) -> Self
[src]

#[must_use]
pub fn from_obj(obj: &K) -> Self where
    K: Resource, 
[src]

impl<K: Resource> ObjectRef<K>[src]

#[must_use]
pub fn new_with(name: &str, dyntype: K::DynamicType) -> Self
[src]

#[must_use]
pub fn within(self, namespace: &str) -> Self
[src]

#[must_use]
pub fn from_obj_with(obj: &K, dyntype: K::DynamicType) -> Self where
    K: Resource, 
[src]

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

#[must_use]
pub fn from_owner_ref(
    namespace: Option<&str>,
    owner: &OwnerReference,
    dyntype: K::DynamicType
) -> Option<Self>
[src]

Create an ObjectRef from an OwnerReference

Returns None if the types do not match.

#[must_use]
pub fn into_kind_unchecked<K2: Resource>(
    self,
    dt2: K2::DynamicType
) -> ObjectRef<K2>
[src]

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>[src]

Trait Implementations

impl<K: Resource> Clone for ObjectRef<K> where
    K::DynamicType: Clone
[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<K: Resource> Debug for ObjectRef<K> where
    K::DynamicType: Debug
[src]

fn fmt(&self, __f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<K: Resource> Display for ObjectRef<K>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<K: Resource> Hash for ObjectRef<K> where
    K::DynamicType: Hash
[src]

fn hash<__HK>(&self, __state: &mut __HK) where
    __HK: Hasher
[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<K: Resource> PartialEq<ObjectRef<K>> for ObjectRef<K> where
    K::DynamicType: PartialEq
[src]

fn eq(&self, other: &Self) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl<K: Resource> Eq for ObjectRef<K> where
    K::DynamicType: Eq
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.