Skip to content

Commit 8421acb

Browse files
authored
chore: apply rustfmt to interop changes (#33)
Signed-off-by: Luca Muscariello <muscariello@ieee.org>
1 parent 6d1320d commit 8421acb

File tree

8 files changed

+56
-40
lines changed

8 files changed

+56
-40
lines changed

a2a-client/src/jsonrpc.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ impl Transport for JsonRpcTransport {
341341
params: &ServiceParams,
342342
req: &CreateTaskPushNotificationConfigRequest,
343343
) -> Result<TaskPushNotificationConfig, A2AError> {
344-
let result = self.call_value(params, methods::CREATE_PUSH_CONFIG, req).await?;
344+
let result = self
345+
.call_value(params, methods::CREATE_PUSH_CONFIG, req)
346+
.await?;
345347
deserialize_task_push_notification_config(result)
346348
}
347349

@@ -350,7 +352,9 @@ impl Transport for JsonRpcTransport {
350352
params: &ServiceParams,
351353
req: &GetTaskPushNotificationConfigRequest,
352354
) -> Result<TaskPushNotificationConfig, A2AError> {
353-
let result = self.call_value(params, methods::GET_PUSH_CONFIG, req).await?;
355+
let result = self
356+
.call_value(params, methods::GET_PUSH_CONFIG, req)
357+
.await?;
354358
deserialize_task_push_notification_config(result)
355359
}
356360

@@ -359,7 +363,9 @@ impl Transport for JsonRpcTransport {
359363
params: &ServiceParams,
360364
req: &ListTaskPushNotificationConfigsRequest,
361365
) -> Result<ListTaskPushNotificationConfigsResponse, A2AError> {
362-
let result = self.call_value(params, methods::LIST_PUSH_CONFIGS, req).await?;
366+
let result = self
367+
.call_value(params, methods::LIST_PUSH_CONFIGS, req)
368+
.await?;
363369
deserialize_list_task_push_notification_configs_response(result)
364370
}
365371

a2a-client/src/push_config_compat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ mod tests {
101101
assert_eq!(parsed.configs, configs);
102102
assert_eq!(parsed.next_page_token, None);
103103
}
104-
}
104+
}

a2a-client/src/rest.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,10 @@ impl Transport for RestTransport {
393393
) -> Result<TaskPushNotificationConfig, A2AError> {
394394
let payload = self
395395
.post_value(
396-
&format!("/tasks/{}/pushNotificationConfigs", req.task_id),
397-
params,
398-
&req.config,
399-
)
396+
&format!("/tasks/{}/pushNotificationConfigs", req.task_id),
397+
params,
398+
&req.config,
399+
)
400400
.await?;
401401
deserialize_task_push_notification_config(payload)
402402
}
@@ -408,10 +408,10 @@ impl Transport for RestTransport {
408408
) -> Result<TaskPushNotificationConfig, A2AError> {
409409
let payload = self
410410
.get_value(
411-
&format!("/tasks/{}/pushNotificationConfigs/{}", req.task_id, req.id),
412-
params,
413-
&[],
414-
)
411+
&format!("/tasks/{}/pushNotificationConfigs/{}", req.task_id, req.id),
412+
params,
413+
&[],
414+
)
415415
.await?;
416416
deserialize_task_push_notification_config(payload)
417417
}
@@ -431,10 +431,10 @@ impl Transport for RestTransport {
431431

432432
let payload = self
433433
.get_value(
434-
&format!("/tasks/{}/pushNotificationConfigs", req.task_id),
435-
params,
436-
&query_parts,
437-
)
434+
&format!("/tasks/{}/pushNotificationConfigs", req.task_id),
435+
params,
436+
&query_parts,
437+
)
438438
.await?;
439439
deserialize_list_task_push_notification_configs_response(payload)
440440
}

a2a-server/src/handler.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,16 +809,16 @@ impl RequestHandler for DefaultRequestHandler {
809809
#[cfg(test)]
810810
mod tests {
811811
use super::*;
812+
use crate::executor::ExecutorContext;
813+
use crate::push::InMemoryPushConfigStore;
814+
use crate::task_store::InMemoryTaskStore;
812815
use axum::{
813816
Router,
814817
body::Bytes,
815818
extract::State,
816819
http::{HeaderMap, StatusCode, header},
817820
routing::post,
818821
};
819-
use crate::executor::ExecutorContext;
820-
use crate::push::InMemoryPushConfigStore;
821-
use crate::task_store::InMemoryTaskStore;
822822
use futures::stream;
823823
use std::sync::Arc;
824824
use tokio::{
@@ -1052,15 +1052,16 @@ mod tests {
10521052
StatusCode::ACCEPTED
10531053
}
10541054

1055-
async fn start_push_webhook(
1056-
) -> (
1055+
async fn start_push_webhook() -> (
10571056
String,
10581057
mpsc::UnboundedReceiver<CapturedPush>,
10591058
oneshot::Sender<()>,
10601059
tokio::task::JoinHandle<()>,
10611060
) {
10621061
let (sender, receiver) = mpsc::unbounded_channel();
1063-
let app = Router::new().route("/", post(capture_push)).with_state(sender);
1062+
let app = Router::new()
1063+
.route("/", post(capture_push))
1064+
.with_state(sender);
10641065
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
10651066
let address = listener.local_addr().unwrap();
10661067
let (shutdown_tx, shutdown_rx) = oneshot::channel();

a2a-server/src/jsonrpc.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ mod tests {
444444
});
445445
let resp = post_jsonrpc(app, methods::CREATE_PUSH_CONFIG, params).await;
446446
assert!(resp.error.is_none(), "unexpected error: {:?}", resp.error);
447-
let result = serde_json::from_value::<TaskPushNotificationConfig>(resp.result.unwrap()).unwrap();
447+
let result =
448+
serde_json::from_value::<TaskPushNotificationConfig>(resp.result.unwrap()).unwrap();
448449
assert_eq!(result.task_id, "t1");
449450
assert_eq!(result.config.id.as_deref(), Some("cfg1"));
450451
assert_eq!(result.config.url, "http://example.com/callback");
@@ -462,7 +463,8 @@ mod tests {
462463
});
463464
let resp = post_jsonrpc(app, methods::CREATE_PUSH_CONFIG, params).await;
464465
assert!(resp.error.is_none(), "unexpected error: {:?}", resp.error);
465-
let result = serde_json::from_value::<TaskPushNotificationConfig>(resp.result.unwrap()).unwrap();
466+
let result =
467+
serde_json::from_value::<TaskPushNotificationConfig>(resp.result.unwrap()).unwrap();
466468
assert_eq!(result.task_id, "t1");
467469
assert_eq!(result.config.id.as_deref(), Some("cfg1"));
468470
assert_eq!(result.config.url, "http://example.com/callback");
@@ -487,8 +489,9 @@ mod tests {
487489
});
488490
let resp = post_jsonrpc(app, methods::LIST_PUSH_CONFIGS, params).await;
489491
assert!(resp.error.is_none(), "unexpected error: {:?}", resp.error);
490-
let result = serde_json::from_value::<Vec<TaskPushNotificationConfig>>(resp.result.unwrap())
491-
.unwrap();
492+
let result =
493+
serde_json::from_value::<Vec<TaskPushNotificationConfig>>(resp.result.unwrap())
494+
.unwrap();
492495
assert!(result.is_empty());
493496
}
494497

a2a-server/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub mod executor;
55
pub mod handler;
66
pub mod jsonrpc;
77
pub mod middleware;
8-
mod push_config_compat;
98
pub mod push;
9+
mod push_config_compat;
1010
pub mod rest;
1111
pub mod sse;
1212
pub mod task_store;

a2a-server/src/push_config_compat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ use serde_json::Value;
77
pub(crate) fn json_value<T: Serialize>(value: &T) -> Result<Value, A2AError> {
88
serde_json::to_value(value)
99
.map_err(|e| A2AError::internal(format!("failed to serialize JSON payload: {e}")))
10-
}
10+
}

examples/helloworld/tests/transports_e2e.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use a2a_server::jsonrpc::jsonrpc_router;
1313
use a2a_server::rest::rest_router;
1414
use a2a_server::{
1515
DefaultRequestHandler, ExecutorContext, HttpPushSender, InMemoryPushConfigStore,
16-
InMemoryTaskStore, RequestHandler, ServiceParams,
17-
WELL_KNOWN_AGENT_CARD_PATH,
16+
InMemoryTaskStore, RequestHandler, ServiceParams, WELL_KNOWN_AGENT_CARD_PATH,
1817
};
1918
use async_trait::async_trait;
2019
use axum::body::Bytes;
@@ -271,7 +270,10 @@ impl RequestHandler for TestHandler {
271270
}
272271

273272
impl a2a_server::AgentExecutor for PushTransportExecutor {
274-
fn execute(&self, ctx: ExecutorContext) -> BoxStream<'static, Result<StreamResponse, A2AError>> {
273+
fn execute(
274+
&self,
275+
ctx: ExecutorContext,
276+
) -> BoxStream<'static, Result<StreamResponse, A2AError>> {
275277
let working = StreamResponse::StatusUpdate(TaskStatusUpdateEvent {
276278
task_id: ctx.task_id.clone(),
277279
context_id: ctx.context_id.clone(),
@@ -346,10 +348,7 @@ async fn spawn_http_server() -> (String, tokio::task::JoinHandle<()>) {
346348
async fn spawn_push_http_server() -> (String, tokio::task::JoinHandle<()>) {
347349
let handler = Arc::new(
348350
DefaultRequestHandler::new(PushTransportExecutor, InMemoryTaskStore::new())
349-
.with_push_notifications(
350-
InMemoryPushConfigStore::new(),
351-
HttpPushSender::new(None),
352-
),
351+
.with_push_notifications(InMemoryPushConfigStore::new(), HttpPushSender::new(None)),
353352
);
354353
let app = Router::new()
355354
.nest("/rest", rest_router(handler.clone()))
@@ -389,14 +388,15 @@ async fn capture_push(
389388
StatusCode::ACCEPTED
390389
}
391390

392-
async fn spawn_webhook_server(
393-
) -> (
391+
async fn spawn_webhook_server() -> (
394392
String,
395393
mpsc::UnboundedReceiver<CapturedPush>,
396394
tokio::task::JoinHandle<()>,
397395
) {
398396
let (sender, receiver) = mpsc::unbounded_channel();
399-
let app = Router::new().route("/", post(capture_push)).with_state(sender);
397+
let app = Router::new()
398+
.route("/", post(capture_push))
399+
.with_state(sender);
400400
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
401401
let addr = listener.local_addr().unwrap();
402402
let handle = tokio::spawn(async move {
@@ -861,7 +861,10 @@ async fn rest_transport_push_delivery_end_to_end() {
861861
assert!(matches!(response, SendMessageResponse::Task(_)));
862862

863863
let first = recv_push(&mut receiver).await;
864-
assert_eq!(first.authorization.as_deref(), Some("Basic dGVzdDpzZWNyZXQ="));
864+
assert_eq!(
865+
first.authorization.as_deref(),
866+
Some("Basic dGVzdDpzZWNyZXQ=")
867+
);
865868
assert_eq!(first.notification_token.as_deref(), Some("rest-token"));
866869
match first.event {
867870
StreamResponse::StatusUpdate(update) => {
@@ -872,7 +875,10 @@ async fn rest_transport_push_delivery_end_to_end() {
872875
}
873876

874877
let second = recv_push(&mut receiver).await;
875-
assert_eq!(second.authorization.as_deref(), Some("Basic dGVzdDpzZWNyZXQ="));
878+
assert_eq!(
879+
second.authorization.as_deref(),
880+
Some("Basic dGVzdDpzZWNyZXQ=")
881+
);
876882
assert_eq!(second.notification_token.as_deref(), Some("rest-token"));
877883
match second.event {
878884
StreamResponse::Task(task) => {

0 commit comments

Comments
 (0)