kube_core::labels

Struct Selector

source
pub struct Selector(/* private fields */);
Expand description

Perform selection on a list of expressions

Can be injected into WatchParams or ListParams.

Implementations§

source§

impl Selector

source

pub fn selects_all(&self) -> bool

Indicates whether this label selector matches everything

source

pub fn extend( &mut self, exprs: impl IntoIterator<Item = Expression>, ) -> &mut Self

Extend the list of expressions for the selector

use kube::core::{Selector, Expression};
use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;

let mut selector = Selector::default();

// Extend from expressions:
selector.extend(Expression::Equal("environment".into(), "production".into()));
selector.extend([Expression::Exists("bar".into()), Expression::Exists("foo".into())].into_iter());

// Extend from native selectors:
let label_selector: Selector = LabelSelector::default().try_into()?;
selector.extend(label_selector);

Trait Implementations§

source§

impl Clone for Selector

source§

fn clone(&self) -> Selector

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Selector

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Selector

source§

fn default() -> Selector

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Selector

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Selector

source§

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

Convert a selector to a string for the API

source§

impl From<Expression> for Selector

source§

fn from(value: Expression) -> Self

Converts to this type from the input type.
source§

impl From<Selector> for LabelSelector

source§

fn from(value: Selector) -> Self

Converts to this type from the input type.
source§

impl FromIterator<(&'static str, &'static str)> for Selector

source§

fn from_iter<T: IntoIterator<Item = (&'static str, &'static str)>>( iter: T, ) -> Self

use kube_core::{Selector, Expression};

let sel: Selector = Some(("foo", "bar")).into_iter().collect();
let equal: Selector = Expression::Equal("foo".into(), "bar".into()).into();
assert_eq!(sel, equal)
source§

impl FromIterator<(String, String)> for Selector

source§

fn from_iter<T: IntoIterator<Item = (String, String)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Expression> for Selector

source§

fn from_iter<T: IntoIterator<Item = Expression>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl IntoIterator for Selector

source§

type IntoIter = IntoIter<<Selector as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

type Item = Expression

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for Selector

source§

fn eq(&self, other: &Selector) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SelectorExt for Selector

source§

fn matches(&self, labels: &BTreeMap<String, String>) -> bool

Perform a match check on the resource labels

source§

type Search = BTreeMap<String, String>

Collection type to compare with self
source§

impl Serialize for Selector

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<LabelSelector> for Selector

source§

type Error = ParseExpressionError

The type returned in the event of a conversion error.
source§

fn try_from(value: LabelSelector) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Selector

source§

impl StructuralPartialEq for Selector

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,