Skip to main content

ExpandQuery

Struct ExpandQuery 

Source
pub struct ExpandQuery { /* private fields */ }
Expand description

Builder for Redfish $expand query parameters according to DSP0266 specification.

The $expand query parameter allows clients to request that the server expand navigation properties inline instead of returning just references. This is particularly useful for reducing the number of HTTP requests needed to retrieve related data.

According to the Redfish specification Table 9, the supported expand options are:

OptionDescriptionExample URL
*Expand all hyperlinks, including payload annotations?$expand=*
.Expand hyperlinks not in links property instances?$expand=.
~Expand hyperlinks in links property instances?$expand=~
$levelsNumber of levels to cascade expansion?$expand=.($levels=2)

§Examples

use nv_redfish_core::query::ExpandQuery;

// Default: expand current resource one level
let default = ExpandQuery::default();
assert_eq!(default.to_query_string(), "$expand=.($levels=1)");

// Expand all hyperlinks
let all = ExpandQuery::all();
assert_eq!(all.to_query_string(), "$expand=*($levels=1)");

// Expand with multiple levels
let deep = ExpandQuery::current().levels(3);
assert_eq!(deep.to_query_string(), "$expand=.($levels=3)");

// Expand specific navigation property
let thermal = ExpandQuery::property("Thermal");
assert_eq!(thermal.to_query_string(), "$expand=Thermal($levels=1)");

Implementations§

Source§

impl ExpandQuery

Source

pub fn new() -> Self

Create a new expand query with default values.

This is equivalent to ExpandQuery::default() and creates a query that expands the current resource one level deep: $expand=.($levels=1).

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::new();
assert_eq!(query.to_query_string(), "$expand=.($levels=1)");

Expand all hyperlinks excluding links.

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::no_links();
assert_eq!(query.to_query_string(), "$expand=.");
Source

pub fn all() -> Self

Expand all hyperlinks, including those in payload annotations.

This expands all hyperlinks found in the resource, including those in payload annotations such as @Redfish.Settings, @Redfish.ActionInfo, and @Redfish.CollectionCapabilities.

Equivalent to: $expand=*

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::all();
assert_eq!(query.to_query_string(), "$expand=*($levels=1)");

// With multiple levels
let deep = ExpandQuery::all().levels(3);
assert_eq!(deep.to_query_string(), "$expand=*($levels=3)");
Source

pub fn current() -> Self

Expand all hyperlinks not in any links property instances of the resource.

This expands hyperlinks found directly in the resource properties, but not those in dedicated Links sections. Includes payload annotations.

Equivalent to: $expand=.

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::current();
assert_eq!(query.to_query_string(), "$expand=.($levels=1)");

Expand all hyperlinks found in all links property instances of the resource.

This expands only hyperlinks found in Links sections of the resource, which typically contain references to related resources.

Equivalent to: $expand=~

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::links();
assert_eq!(query.to_query_string(), "$expand=~($levels=1)");
Source

pub fn property<S: Into<String>>(property: S) -> Self

Expand a specific navigation property.

This expands only the specified navigation property, which is useful when you know exactly which related data you need.

§Arguments
  • property - The name of the navigation property to expand
§Examples
use nv_redfish_core::query::ExpandQuery;

let thermal = ExpandQuery::property("Thermal");
assert_eq!(thermal.to_query_string(), "$expand=Thermal($levels=1)");

let members = ExpandQuery::property("Members");
assert_eq!(members.to_query_string(), "$expand=Members($levels=1)");
Source

pub fn properties(properties: &[&str]) -> Self

Expand multiple specific navigation properties.

This allows expanding several navigation properties in a single request, which is more efficient than making separate requests for each property.

§Arguments
  • properties - A slice of navigation property names to expand
§Examples
use nv_redfish_core::query::ExpandQuery;

let env = ExpandQuery::properties(&["Thermal", "Power"]);
assert_eq!(env.to_query_string(), "$expand=Thermal,Power($levels=1)");

let system = ExpandQuery::properties(&["Processors", "Memory", "Storage"]);
assert_eq!(system.to_query_string(), "$expand=Processors,Memory,Storage($levels=1)");
Source

pub const fn levels(self, levels: u32) -> Self

Set the number of levels to cascade the expand operation.

The $levels parameter controls how deep the expansion goes:

  • Level 1: Expand hyperlinks in the current resource
  • Level 2: Also expand hyperlinks in the resources expanded at level 1
  • And so on…
§Arguments
  • levels - Number of levels to expand (typically 1-6 in practice)
§Examples
use nv_redfish_core::query::ExpandQuery;

let shallow = ExpandQuery::current().levels(1);
assert_eq!(shallow.to_query_string(), "$expand=.($levels=1)");

let deep = ExpandQuery::all().levels(3);
assert_eq!(deep.to_query_string(), "$expand=*($levels=3)");
Source

pub fn to_query_string(&self) -> String

Convert to the OData query string according to Redfish specification.

This generates the actual query parameter string that will be appended to HTTP requests to Redfish services.

§Returns

A query string in the format $expand=expression($levels=n) or just $expand=expression if no levels are specified.

§Examples
use nv_redfish_core::query::ExpandQuery;

let query = ExpandQuery::property("Thermal").levels(2);
assert_eq!(query.to_query_string(), "$expand=Thermal($levels=2)");

let query = ExpandQuery::all();
assert_eq!(query.to_query_string(), "$expand=*($levels=1)");

Trait Implementations§

Source§

impl Clone for ExpandQuery

Source§

fn clone(&self) -> ExpandQuery

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 ExpandQuery

Source§

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

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

impl Default for ExpandQuery

Source§

fn default() -> Self

Default expand query: $expand=.($levels=1) Expands all hyperlinks not in any links property instances of the resource

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.