AirClient

Struct AirClient 

Source
pub struct AirClient {
    client: Option<Arc<Mutex<AirServiceClient<Channel>>>>,
    address: String,
}
Expand description

Air gRPC client wrapper that handles connection to the Air daemon service. This provides a clean interface for Mountain to interact with Air’s capabilities including update management, authentication, file indexing, and system monitoring.

Fields§

§client: Option<Arc<Mutex<AirServiceClient<Channel>>>>

The underlying tonic gRPC client wrapped in Arc<Mutex<>> for thread-safe access

§address: String

Address of the Air daemon

Implementations§

Source§

impl AirClient

Source

pub async fn new(address: &str) -> Result<Self, CommonError>

Creates a new AirClient and connects to the Air daemon service.

§Arguments
  • address - The gRPC server address (e.g., “http://\[::1\]:50053”)
§Returns
  • Ok(Self) - Successfully created client
  • Err(CommonError) - Connection failure with descriptive error
§Example
use Mountain::Air::AirClient::{AirClient, DEFAULT_AIR_SERVER_ADDRESS};

# #[tokio::main]
# async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = AirClient::new(DEFAULT_AIR_SERVER_ADDRESS).await?;
# Ok(())
# }
Source

pub fn is_connected(&self) -> bool

Checks if the client is connected to the Air daemon.

§Returns
  • true - Client is connected
  • false - Client is not connected
Source

pub fn address(&self) -> &str

Gets the address of the Air daemon.

§Returns

The address string

Source

pub async fn authenticate( &self, request_id: String, username: String, password: String, provider: String, ) -> Result<String, CommonError>

Authenticates a user with the Air daemon.

§Arguments
  • username - User’s username
  • password - User’s password
  • provider - Authentication provider (e.g., “github”, “gitlab”, “microsoft”)
§Returns
  • Ok(token) - Authentication token if successful
  • Err(CommonError) - Authentication failure
Source

pub async fn check_for_updates( &self, request_id: String, current_version: String, channel: String, ) -> Result<UpdateInfo, CommonError>

Checks for available updates.

§Arguments
  • current_version - Current application version
  • channel - Update channel (e.g., “stable”, “beta”, “nightly”)
§Returns
  • Ok(update_info) - Update information if available
  • Err(CommonError) - Check failure
Source

pub async fn download_update( &self, request_id: String, url: String, destination_path: String, checksum: String, headers: HashMap<String, String>, ) -> Result<FileInfo, CommonError>

Downloads an update package.

§Arguments
  • url - URL of the update package
  • destination_path - Local path to save the downloaded file
  • checksum - Optional SHA256 checksum for verification
  • headers - Optional HTTP headers
§Returns
  • Ok(file_info) - Downloaded file information
  • Err(CommonError) - Download failure
Source

pub async fn apply_update( &self, request_id: String, version: String, update_path: String, ) -> Result<(), CommonError>

Applies an update package.

§Arguments
  • version - Version of the update
  • update_path - Path to the update package
§Returns
  • Ok(()) - Update applied successfully
  • Err(CommonError) - Application failure
Source

pub async fn download_file( &self, request_id: String, url: String, destination_path: String, checksum: String, headers: HashMap<String, String>, ) -> Result<FileInfo, CommonError>

Downloads a file.

§Arguments
  • url - URL of the file to download
  • destination_path - Local path to save the downloaded file
  • checksum - Optional SHA256 checksum for verification
  • headers - Optional HTTP headers
§Returns
  • Ok(file_info) - Downloaded file information
  • Err(CommonError) - Download failure
Source

pub async fn download_stream( &self, request_id: String, url: String, headers: HashMap<String, String>, ) -> Result<DownloadStream, CommonError>

Downloads a file as a stream.

This method initiates a streaming download from the given URL, returning a stream of chunks that can be processed incrementally without loading the entire file into memory.

§Arguments
  • request_id - Unique request identifier
  • url - URL of the file to download
  • headers - Optional HTTP headers
§Returns
  • Ok(stream) - Stream that yields download chunks
  • Err(CommonError) - Download initiation failure
§Stream Chunk Information

Each chunk contains:

  • chunk: The binary data chunk
  • total_size: Total file size (if known)
  • downloaded: Number of bytes downloaded so far
  • completed: Whether this is the final chunk
  • error: Error message if download failed
§Example
use Mountain::Air::AirClient::AirClient;
use CommonLibrary::Error::CommonError::CommonError;

# #[tokio::main]
# async fn main() -> Result<(), CommonError> {
# let client = AirClient::new("http://[::1]:50053").await?;
let mut stream = client
	.download_stream(
		"req-123".to_string(),
		"https://example.com/large-file.zip".to_string(),
		std::collections::HashMap::new(),
	)
	.await?;

let mut buffer = Vec::new();
while let Some(chunk) = stream.next().await {
	let chunk = chunk?;
	buffer.extend_from_slice(&chunk.data);
	println!("Downloaded: {} / {} bytes", chunk.downloaded, chunk.total_size);
	if chunk.completed {
		break;
	}
}
# Ok(())
# }
Source

pub async fn index_files( &self, request_id: String, path: String, patterns: Vec<String>, exclude_patterns: Vec<String>, max_depth: u32, ) -> Result<IndexInfo, CommonError>

Indexes files in a directory.

§Arguments
  • path - Path to the directory to index
  • patterns - File patterns to include
  • exclude_patterns - File patterns to exclude
  • max_depth - Maximum depth for recursion
§Returns
  • Ok(index_info) - Index information
  • Err(CommonError) - Indexing failure
Source

pub async fn search_files( &self, request_id: String, query: String, path: String, max_results: u32, ) -> Result<Vec<FileResult>, CommonError>

Searches for files matching a query.

§Arguments
  • query - Search query string
  • path - Path to search in
  • max_results - Maximum number of results to return
§Returns
  • Ok(results) - Search results
  • Err(CommonError) - Search failure
Source

pub async fn get_file_info( &self, request_id: String, path: String, ) -> Result<ExtendedFileInfo, CommonError>

Gets file information.

§Arguments
  • path - Path to the file
§Returns
  • Ok(file_info) - File information
  • Err(CommonError) - Request failure
Source

pub async fn get_status( &self, request_id: String, ) -> Result<AirStatus, CommonError>

Gets the status of the Air daemon.

§Returns
  • Ok(status) - Air daemon status
  • Err(CommonError) - Request failure
Source

pub async fn health_check(&self) -> Result<bool, CommonError>

Performs a health check on the Air daemon.

§Returns
  • Ok(healthy) - Health status
  • Err(CommonError) - Check failure
Source

pub async fn get_metrics( &self, request_id: String, metric_type: Option<String>, ) -> Result<AirMetrics, CommonError>

Gets metrics from the Air daemon.

§Arguments
  • metric_type - Type of metrics (e.g., “performance”, “resources”, “requests”)
§Returns
  • Ok(metrics) - Metrics data
  • Err(CommonError) - Request failure
Source

pub async fn get_resource_usage( &self, request_id: String, ) -> Result<ResourceUsage, CommonError>

Gets resource usage information.

§Arguments
  • request_id - Unique request identifier
§Returns
  • Ok(usage) - Resource usage data
  • Err(CommonError) - Request failure
Source

pub async fn set_resource_limits( &self, request_id: String, memory_limit_mb: u32, cpu_limit_percent: u32, disk_limit_mb: u32, ) -> Result<(), CommonError>

Sets resource limits.

§Arguments
  • request_id - Unique request identifier
  • memory_limit_mb - Memory limit in MB
  • cpu_limit_percent - CPU limit as percentage
  • disk_limit_mb - Disk limit in MB
§Returns
  • Ok(()) - Limits set successfully
  • Err(CommonError) - Set failure
Source

pub async fn get_configuration( &self, request_id: String, section: String, ) -> Result<HashMap<String, String>, CommonError>

Gets configuration.

§Arguments
  • section - Configuration section (e.g., “grpc”, “authentication”, “updates”)
§Returns
  • Ok(config) - Configuration data
  • Err(CommonError) - Request failure
Source

pub async fn update_configuration( &self, request_id: String, section: String, updates: HashMap<String, String>, ) -> Result<(), CommonError>

Updates configuration.

§Arguments
  • section - Configuration section
  • updates - Configuration updates
§Returns
  • Ok(()) - Configuration updated successfully
  • Err(CommonError) - Update failure

Trait Implementations§

Source§

impl Clone for AirClient

Source§

fn clone(&self) -> AirClient

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 AirClient

Source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

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
§

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

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,