Skip to main content

HttpBmc

Struct HttpBmc 

Source
pub struct HttpBmc<C>
where C: HttpClient,
{ /* private fields */ }
Expand description

HTTP-based BMC implementation that wraps an HttpClient.

This struct combines an HTTP client with BMC endpoint information and credentials to provide a complete Redfish client implementation. It implements the Bmc trait to provide standardized access to Redfish services.

§Type Parameters

  • C - The HTTP client implementation to use

Implementations§

Source§

impl<C> HttpBmc<C>

Source

pub fn new( client: C, redfish_endpoint: Url, credentials: BmcCredentials, cache_settings: CacheSettings, ) -> HttpBmc<C>

Create a new HTTP-based BMC client with ETag-based caching.

§Arguments
  • client - The HTTP client implementation to use for requests
  • redfish_endpoint - The base URL of the Redfish service (e.g., https://192.168.1.100)
  • credentials - Authentication credentials for the BMC
§Examples
use nv_redfish_bmc_http::HttpBmc;
use nv_redfish_bmc_http::CacheSettings;
use nv_redfish_bmc_http::BmcCredentials;
use nv_redfish_bmc_http::reqwest::Client;
use url::Url;

let credentials = BmcCredentials::username_password("admin".to_string(), Some("password".to_string()));
let http_client = Client::new()?;
let endpoint = Url::parse("https://192.168.1.100")?;

let bmc = HttpBmc::new(http_client, endpoint, credentials, CacheSettings::default());
Source

pub fn with_custom_headers( client: C, redfish_endpoint: Url, credentials: BmcCredentials, cache_settings: CacheSettings, custom_headers: HeaderMap, ) -> HttpBmc<C>

Create a new HTTP-based BMC client with custom headers and ETag-based caching.

This is an alternative constructor that allows specifying custom HTTP headers that will be included in all requests. Use this when you need vendor-specific headers, custom authentication tokens, or other HTTP headers required by the Redfish service at construction time.

For most use cases, prefer HttpBmc::new which creates a client without custom headers.

§Arguments
  • client - The HTTP client implementation to use for requests
  • redfish_endpoint - The base URL of the Redfish service (e.g., https://192.168.1.100)
  • credentials - Authentication credentials for the BMC
  • cache_settings - Cache configuration for response caching
  • custom_headers - Custom HTTP headers to include in all requests
§Examples
use nv_redfish_bmc_http::HttpBmc;
use nv_redfish_bmc_http::CacheSettings;
use nv_redfish_bmc_http::BmcCredentials;
use nv_redfish_bmc_http::reqwest::Client;
use url::Url;
use http::HeaderMap;

let credentials = BmcCredentials::username_password("admin".to_string(), Some("password".to_string()));
let http_client = Client::new()?;
let endpoint = Url::parse("https://192.168.1.100")?;

// Create custom headers
let mut headers = HeaderMap::new();
headers.insert("X-Auth-Token", "custom-token-value".parse()?);
headers.insert("X-Vendor-Header", "vendor-specific-value".parse()?);

// Create BMC client with custom headers
let bmc = HttpBmc::with_custom_headers(
    http_client,
    endpoint,
    credentials,
    CacheSettings::default(),
    headers,
);

// All requests will include the custom headers
Source

pub fn set_credentials(&self, credentials: BmcCredentials) -> Result<(), String>

Replace the credentials used for subsequent requests.

Existing cache and ETag state is preserved.

§Errors

Returns an error if the credentials lock is poisoned.

Trait Implementations§

Source§

impl<C> Bmc for HttpBmc<C>

Source§

type Error = <C as HttpClient>::Error

BMC Error.
Source§

async fn get<T>( &self, id: &ODataId, ) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>
where T: EntityTypeRef + for<'de> Deserialize<'de> + 'static + Send + Sync,

Get data of the object (navigation property or entity). Read more
Source§

async fn expand<T>( &self, id: &ODataId, query: ExpandQuery, ) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>
where T: Expandable + Send + Sync + 'static,

Expand any expandable object (navigation property or entity). Read more
Source§

async fn create<V, R>( &self, id: &ODataId, v: &V, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
where V: Sync + Send + Serialize, R: Sync + Send + for<'de> Deserialize<'de>,

Creates element of the collection. Read more
Source§

async fn update<V, R>( &self, id: &ODataId, etag: Option<&ODataETag>, v: &V, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
where V: Sync + Send + Serialize, R: Sync + Send + for<'de> Deserialize<'de>,

Update entity. Read more
Source§

async fn delete<T>( &self, id: &ODataId, ) -> Result<ModificationResponse<T>, <HttpBmc<C> as Bmc>::Error>
where T: Sync + Send + for<'de> Deserialize<'de>,

Delete entity.
Source§

async fn action<T, R>( &self, action: &Action<T, R>, params: &T, ) -> Result<ModificationResponse<R>, <HttpBmc<C> as Bmc>::Error>
where T: Sync + Send + Serialize, R: Sync + Send + for<'de> Deserialize<'de>,

Run action. Read more
Source§

async fn filter<T>( &self, id: &ODataId, query: FilterQuery, ) -> Result<Arc<T>, <HttpBmc<C> as Bmc>::Error>
where T: EntityTypeRef + for<'a> Deserialize<'a> + 'static + Send + Sync,

Get and filters data of the object (navigation property or entity). Read more
Source§

async fn stream<T>( &self, uri: &str, ) -> Result<Pin<Box<dyn TryStream<Ok = T, Error = <HttpBmc<C> as Bmc>::Error, Item = Result<T, <HttpBmc<C> as Bmc>::Error>> + Send>>, <HttpBmc<C> as Bmc>::Error>
where T: for<'a> Deserialize<'a> + Send + 'static,

Stream data for the URI. Read more

Auto Trait Implementations§

§

impl<C> !Freeze for HttpBmc<C>

§

impl<C> RefUnwindSafe for HttpBmc<C>
where C: RefUnwindSafe,

§

impl<C> Send for HttpBmc<C>

§

impl<C> Sync for HttpBmc<C>

§

impl<C> Unpin for HttpBmc<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for HttpBmc<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for HttpBmc<C>
where C: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more