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: StringAddress of the Air daemon
Implementations§
Source§impl AirClient
impl AirClient
Sourcepub async fn new(address: &str) -> Result<Self, CommonError>
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 clientErr(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(())
# }Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Checks if the client is connected to the Air daemon.
§Returns
true- Client is connectedfalse- Client is not connected
Sourcepub async fn authenticate(
&self,
request_id: String,
username: String,
password: String,
provider: String,
) -> Result<String, CommonError>
pub async fn authenticate( &self, request_id: String, username: String, password: String, provider: String, ) -> Result<String, CommonError>
Sourcepub async fn check_for_updates(
&self,
request_id: String,
current_version: String,
channel: String,
) -> Result<UpdateInfo, CommonError>
pub async fn check_for_updates( &self, request_id: String, current_version: String, channel: String, ) -> Result<UpdateInfo, CommonError>
Sourcepub async fn download_update(
&self,
request_id: String,
url: String,
destination_path: String,
checksum: String,
headers: HashMap<String, String>,
) -> Result<FileInfo, CommonError>
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 packagedestination_path- Local path to save the downloaded filechecksum- Optional SHA256 checksum for verificationheaders- Optional HTTP headers
§Returns
Ok(file_info)- Downloaded file informationErr(CommonError)- Download failure
Sourcepub async fn apply_update(
&self,
request_id: String,
version: String,
update_path: String,
) -> Result<(), CommonError>
pub async fn apply_update( &self, request_id: String, version: String, update_path: String, ) -> Result<(), CommonError>
Sourcepub async fn download_file(
&self,
request_id: String,
url: String,
destination_path: String,
checksum: String,
headers: HashMap<String, String>,
) -> Result<FileInfo, CommonError>
pub async fn download_file( &self, request_id: String, url: String, destination_path: String, checksum: String, headers: HashMap<String, String>, ) -> Result<FileInfo, CommonError>
Sourcepub async fn download_stream(
&self,
request_id: String,
url: String,
headers: HashMap<String, String>,
) -> Result<DownloadStream, CommonError>
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 identifierurl- URL of the file to downloadheaders- Optional HTTP headers
§Returns
Ok(stream)- Stream that yields download chunksErr(CommonError)- Download initiation failure
§Stream Chunk Information
Each chunk contains:
chunk: The binary data chunktotal_size: Total file size (if known)downloaded: Number of bytes downloaded so farcompleted: Whether this is the final chunkerror: 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(())
# }Sourcepub async fn index_files(
&self,
request_id: String,
path: String,
patterns: Vec<String>,
exclude_patterns: Vec<String>,
max_depth: u32,
) -> Result<IndexInfo, CommonError>
pub async fn index_files( &self, request_id: String, path: String, patterns: Vec<String>, exclude_patterns: Vec<String>, max_depth: u32, ) -> Result<IndexInfo, CommonError>
Sourcepub async fn search_files(
&self,
request_id: String,
query: String,
path: String,
max_results: u32,
) -> Result<Vec<FileResult>, CommonError>
pub async fn search_files( &self, request_id: String, query: String, path: String, max_results: u32, ) -> Result<Vec<FileResult>, CommonError>
Sourcepub async fn get_file_info(
&self,
request_id: String,
path: String,
) -> Result<ExtendedFileInfo, CommonError>
pub async fn get_file_info( &self, request_id: String, path: String, ) -> Result<ExtendedFileInfo, CommonError>
Sourcepub async fn get_status(
&self,
request_id: String,
) -> Result<AirStatus, CommonError>
pub async fn get_status( &self, request_id: String, ) -> Result<AirStatus, CommonError>
Gets the status of the Air daemon.
§Returns
Ok(status)- Air daemon statusErr(CommonError)- Request failure
Sourcepub async fn health_check(&self) -> Result<bool, CommonError>
pub async fn health_check(&self) -> Result<bool, CommonError>
Performs a health check on the Air daemon.
§Returns
Ok(healthy)- Health statusErr(CommonError)- Check failure
Sourcepub async fn get_metrics(
&self,
request_id: String,
metric_type: Option<String>,
) -> Result<AirMetrics, CommonError>
pub async fn get_metrics( &self, request_id: String, metric_type: Option<String>, ) -> Result<AirMetrics, CommonError>
Sourcepub async fn get_resource_usage(
&self,
request_id: String,
) -> Result<ResourceUsage, CommonError>
pub async fn get_resource_usage( &self, request_id: String, ) -> Result<ResourceUsage, CommonError>
Sourcepub async fn set_resource_limits(
&self,
request_id: String,
memory_limit_mb: u32,
cpu_limit_percent: u32,
disk_limit_mb: u32,
) -> Result<(), CommonError>
pub async fn set_resource_limits( &self, request_id: String, memory_limit_mb: u32, cpu_limit_percent: u32, disk_limit_mb: u32, ) -> Result<(), CommonError>
Sourcepub async fn get_configuration(
&self,
request_id: String,
section: String,
) -> Result<HashMap<String, String>, CommonError>
pub async fn get_configuration( &self, request_id: String, section: String, ) -> Result<HashMap<String, String>, CommonError>
Sourcepub async fn update_configuration(
&self,
request_id: String,
section: String,
updates: HashMap<String, String>,
) -> Result<(), CommonError>
pub async fn update_configuration( &self, request_id: String, section: String, updates: HashMap<String, String>, ) -> Result<(), CommonError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AirClient
impl !RefUnwindSafe for AirClient
impl Send for AirClient
impl Sync for AirClient
impl Unpin for AirClient
impl !UnwindSafe for AirClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].