RoutingParameter

Struct RoutingParameter 

Source
#[non_exhaustive]
pub struct RoutingParameter { pub field: String, pub path_template: String, /* private fields */ }
Expand description

A projection from an input message to the GRPC or REST header.

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.
§field: String

A request field to extract the header key-value pair from.

§path_template: String

A pattern matching the key-value field. Optional. If not specified, the whole field specified in the field field will be taken as value, and its name used as key. If specified, it MUST contain exactly one named segment (along with any number of unnamed segments) The pattern will be matched over the field specified in the field field, then if the match is successful:

  • the name of the single named segment will be used as a header name,
  • the match value of the segment will be used as a header value; if the match is NOT successful, nothing will be sent.

Example:

          -- This is a field in the request message
         |   that the header value will be extracted from.
         |
         |                     -- This is the key name in the
         |                    |   routing header.
         V                    |
field: "table_name"           v
path_template: "projects/*/{table_location=instances/*}/tables/*"
                                           ^            ^
                                           |            |
  In the {} brackets is the pattern that --             |
  specifies what to extract from the                    |
  field as a value to be sent.                          |
                                                        |
 The string in the field must match the whole pattern --
 before brackets, inside brackets, after brackets.

When looking at this specific example, we can see that:

  • A key-value pair with the key table_location and the value matching instances/* should be added to the x-goog-request-params routing header.
  • The value is extracted from the request message’s table_name field if it matches the full pattern specified: projects/*/instances/*/tables/*.

NB: If the path_template field is not provided, the key name is equal to the field name, and the whole field should be sent as a value. This makes the pattern for the field and the value functionally equivalent to **, and the configuration

{
  field: "table_name"
}

is a functionally equivalent shorthand to:

{
  field: "table_name"
  path_template: "{table_name=**}"
}

See Example 1 for more details.

Implementations§

Source§

impl RoutingParameter

Source

pub fn new() -> Self

Source

pub fn set_field<T: Into<String>>(self, v: T) -> Self

Sets the value of field.

Source

pub fn set_path_template<T: Into<String>>(self, v: T) -> Self

Sets the value of path_template.

Trait Implementations§

Source§

impl Clone for RoutingParameter

Source§

fn clone(&self) -> RoutingParameter

Returns a duplicate 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 RoutingParameter

Source§

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

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

impl Default for RoutingParameter

Source§

fn default() -> RoutingParameter

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

impl Message for RoutingParameter

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for RoutingParameter

Source§

fn eq(&self, other: &RoutingParameter) -> 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 StructuralPartialEq for RoutingParameter

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, 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>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,