Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity committed Aug 23, 2024
1 parent 6de44e4 commit 400a6da
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ic-agent/src/agent/agent_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct AgentConfig {
pub identity: Arc<dyn Identity>,
/// See [`with_ingress_expiry`](super::AgentBuilder::with_ingress_expiry).
pub ingress_expiry: Option<Duration>,
/// See [`with_client`](super::AgentBuilder::with_client).
/// See [`with_http_client`](super::AgentBuilder::with_http_client).
pub client: Option<Client>,
/// See [`with_route_provider`](super::AgentBuilder::with_route_provider).
pub route_provider: Option<Arc<dyn RouteProvider>>,
Expand Down
2 changes: 1 addition & 1 deletion ic-agent/src/agent/agent_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub enum AgentError {

/// An unknown error occurred during communication with the replica.
#[error("An error happened during communication with the replica: {0}")]
TransportError(Box<dyn std::error::Error + Send + Sync>),
TransportError(#[from] reqwest::Error),

/// There was a mismatch between the expected and actual CBOR data during inspection.
#[error("There is a mismatch between the CBOR encoded call and the arguments: field {field}, value in argument is {value_arg}, value in CBOR is {value_cbor}")]
Expand Down
2 changes: 0 additions & 2 deletions ic-agent/src/agent/agent_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Disable these tests without the reqwest feature.

use self::mock::{
assert_mock, assert_single_mock, assert_single_mock_count, mock, mock_additional,
};
Expand Down
3 changes: 1 addition & 2 deletions ic-agent/src/agent/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ impl AgentBuilder {
self.with_arc_identity(Arc::from(identity))
}

/// Same as [`Self::with_identity`], but provides a `Arc` boxed implementation instead
/// of a direct type.
/// Same as [`Self::with_identity`], but reuses an existing `Arc`
pub fn with_arc_identity(mut self, identity: Arc<dyn Identity>) -> Self {
self.config.identity = identity;
self
Expand Down
2 changes: 1 addition & 1 deletion ic-agent/src/agent/http_transport/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! This module has been removed in favor of builder methods on `AgentBuilder`.
//! This module has been deprecated in favor of builder methods on `AgentBuilder`.

#[deprecated(since = "0.38.0", note = "use the AgentBuilder methods")]
#[doc(hidden)]
Expand Down
10 changes: 5 additions & 5 deletions ic-agent/src/agent/http_transport/reqwest_transport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! A [`Transport`] that connects using a [`reqwest`] client.
//! This module has been deprecated in favor of builder methods on `AgentBuilder`.
#![allow(deprecated)]
pub use reqwest;
use std::{sync::Arc, time::Duration};
Expand Down Expand Up @@ -45,20 +45,20 @@ impl ReqwestTransport {
}
}

/// Equivalent to [`AgentBuilder::with_url`] and [`AgentBuilder::with_client`].
/// Equivalent to [`AgentBuilder::with_url`] and [`AgentBuilder::with_http_client`].
#[deprecated(
since = "0.38.0",
note = "Use AgentBuilder::with_url and AgentBuilder::with_client"
note = "Use AgentBuilder::with_url and AgentBuilder::with_http_client"
)]
pub fn create_with_client<U: Into<String>>(url: U, client: Client) -> Result<Self, AgentError> {
let route_provider = Arc::new(RoundRobinRouteProvider::new(vec![url.into()])?);
Self::create_with_client_route(route_provider, client)
}

/// Equivalent to [`AgentBuilder::with_client`] and [`AgentBuilder::with_route_provider`].
/// Equivalent to [`AgentBuilder::with_http_client`] and [`AgentBuilder::with_route_provider`].
#[deprecated(
since = "0.38.0",
note = "Use AgentBuilder::with_client and AgentBuilder::with_arc_route_provider"
note = "Use AgentBuilder::with_http_client and AgentBuilder::with_arc_route_provider"
)]
pub fn create_with_client_route(
route_provider: Arc<dyn RouteProvider>,
Expand Down
10 changes: 5 additions & 5 deletions ic-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl Agent {
/// Set the identity provider for signing messages.
///
/// NOTE: if you change the identity while having update calls in
/// flight, you will not be able to [Agent::poll] the status of these
/// flight, you will not be able to [`Agent::request_status_raw`] the status of these
/// messages.
pub fn set_identity<I>(&mut self, identity: I)
where
Expand All @@ -230,7 +230,7 @@ impl Agent {
/// Set the arc identity provider for signing messages.
///
/// NOTE: if you change the identity while having update calls in
/// flight, you will not be able to [Agent::poll] the status of these
/// flight, you will not be able to [`Agent::request_status_raw`] the status of these
/// messages.
pub fn set_arc_identity(&mut self, identity: Arc<dyn Identity>) {
self.identity = identity;
Expand Down Expand Up @@ -1165,12 +1165,12 @@ impl Agent {
// Network-related errors can be retried.
if err.is_connect() {
if retry_count >= self.max_tcp_error_retries {
return Err(AgentError::TransportError(Box::new(err)));
return Err(AgentError::TransportError(err));
}
retry_count += 1;
continue;
}
return Err(AgentError::TransportError(Box::new(err)));
return Err(AgentError::TransportError(err));
}
}
}
Expand All @@ -1195,7 +1195,7 @@ impl Agent {
let mut stream = response.bytes_stream();

while let Some(chunk) = stream.next().await {
let chunk = chunk.map_err(|x| AgentError::TransportError(Box::new(x)))?;
let chunk = chunk?;

// Size Check (Body Size)
if matches!(self
Expand Down
4 changes: 2 additions & 2 deletions ic-identity-hsm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
//! # Example
//!
//! ```rust,no_run
//! use ic_agent::agent::{Agent, http_transport::ReqwestTransport};
//! use ic_agent::agent::Agent;
//! use ic_identity_hsm::HardwareIdentity;
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # let replica_url = "";
//! # let lib_path = "";
//! # let slot_index = 0;
//! # let key_id = "";
//! let agent = Agent::builder()
//! .with_transport(ReqwestTransport::create(replica_url)?)
//! .with_url(replica_url)
//! .with_identity(HardwareIdentity::new(lib_path, slot_index, key_id, || Ok("hunter2".to_string()))?)
//! .build();
//! # Ok(())
Expand Down
2 changes: 1 addition & 1 deletion ic-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
pub mod call;
/// A higher-level canister type for managing various aspects of a canister.
pub mod canister;
/// A few known canister types for use with [`Canister`](canister::Canister).
/// A few known canister types for use with [`Canister`].
pub mod interfaces;

pub use canister::{Argument, Canister};

0 comments on commit 400a6da

Please sign in to comment.