Skip to content

Commit 6376b32

Browse files
rename macro
1 parent 1d633b7 commit 6376b32

26 files changed

+65
-54
lines changed

Diff for: src/operation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ impl<'a, O> OperationResponse<'a, O> {
9797
}
9898
}
9999

100-
macro_rules! sync {
100+
macro_rules! handle_response_sync {
101101
($result:block) => {
102102
let result = || $result;
103103
OperationResponse::Sync(result())
104104
};
105105
}
106-
use sync;
106+
use handle_response_sync;
107107

108108
/// A trait modeling the behavior of a server side operation.
109109
///

Diff for: src/operation/abort_transaction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
ClientSession,
1212
};
1313

14-
use super::{sync, OperationResponse, OperationWithDefaults, WriteConcernOnlyBody};
14+
use super::{handle_response_sync, OperationResponse, OperationWithDefaults, WriteConcernOnlyBody};
1515

1616
pub(crate) struct AbortTransaction {
1717
write_concern: Option<WriteConcern>,
@@ -56,7 +56,7 @@ impl OperationWithDefaults for AbortTransaction {
5656
_description: &'a StreamDescription,
5757
_session: Option<&'a mut ClientSession>,
5858
) -> OperationResponse<'a, Self::O> {
59-
sync! {{
59+
handle_response_sync! {{
6060
let response: WriteConcernOnlyBody = response.body()?;
6161
response.validate()
6262
}}

Diff for: src/operation/aggregate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
};
1414

1515
use super::{
16-
sync,
16+
handle_response_sync,
1717
CursorBody,
1818
OperationResponse,
1919
OperationWithDefaults,
@@ -98,7 +98,7 @@ impl OperationWithDefaults for Aggregate {
9898
description: &'a StreamDescription,
9999
_session: Option<&mut ClientSession>,
100100
) -> OperationResponse<'static, Self::O> {
101-
sync! {{
101+
handle_response_sync! {{
102102
let cursor_response: CursorBody = response.body()?;
103103

104104
if self.is_out_or_merge() {

Diff for: src/operation/aggregate/change_stream.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
ClientSession,
1010
};
1111

12-
use super::{sync, Aggregate, OperationResponse};
12+
use super::{handle_response_sync, Aggregate, OperationResponse};
1313

1414
pub(crate) struct ChangeStreamAggregate {
1515
inner: Aggregate,
@@ -89,7 +89,7 @@ impl OperationWithDefaults for ChangeStreamAggregate {
8989
description: &'a StreamDescription,
9090
session: Option<&'a mut ClientSession>,
9191
) -> OperationResponse<'static, Self::O> {
92-
sync! {{
92+
handle_response_sync! {{
9393
let op_time = response
9494
.raw_body()
9595
.get("operationTime")?

Diff for: src/operation/commit_transaction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
ClientSession,
1111
};
1212

13-
use super::{sync, OperationResponse, WriteConcernOnlyBody};
13+
use super::{handle_response_sync, OperationResponse, WriteConcernOnlyBody};
1414

1515
pub(crate) struct CommitTransaction {
1616
options: Option<TransactionOptions>,
@@ -49,7 +49,7 @@ impl OperationWithDefaults for CommitTransaction {
4949
_description: &StreamDescription,
5050
_session: Option<&mut ClientSession>,
5151
) -> OperationResponse<'static, Self::O> {
52-
sync! {{
52+
handle_response_sync! {{
5353
let response: WriteConcernOnlyBody = response.body()?;
5454
response.validate()
5555
}}

Diff for: src/operation/count.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
ClientSession,
1212
};
1313

14-
use super::{sync, OperationResponse};
14+
use super::{handle_response_sync, OperationResponse};
1515

1616
pub(crate) struct Count {
1717
ns: Namespace,
@@ -51,7 +51,7 @@ impl OperationWithDefaults for Count {
5151
_description: &StreamDescription,
5252
_session: Option<&mut ClientSession>,
5353
) -> OperationResponse<'static, Self::O> {
54-
sync! {{
54+
handle_response_sync! {{
5555
let response_body: ResponseBody = response.body()?;
5656
Ok(response_body.n)
5757
}}

Diff for: src/operation/count_documents.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ use crate::{
1313
Namespace,
1414
};
1515

16-
use super::{sync, OperationResponse, OperationWithDefaults, Retryability, SingleCursorResult};
16+
use super::{
17+
handle_response_sync,
18+
OperationResponse,
19+
OperationWithDefaults,
20+
Retryability,
21+
SingleCursorResult,
22+
};
1723

1824
pub(crate) struct CountDocuments {
1925
aggregate: Aggregate,
@@ -95,7 +101,7 @@ impl OperationWithDefaults for CountDocuments {
95101
_description: &StreamDescription,
96102
_session: Option<&mut ClientSession>,
97103
) -> OperationResponse<'static, Self::O> {
98-
sync! {{
104+
handle_response_sync! {{
99105
let response: SingleCursorResult<Body> = response.body()?;
100106
Ok(response.0.map(|r| r.n).unwrap_or(0))
101107
}}

Diff for: src/operation/create.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
Namespace,
1616
};
1717

18-
use super::{sync, OperationResponse};
18+
use super::{handle_response_sync, OperationResponse};
1919

2020
#[derive(Debug)]
2121
pub(crate) struct Create {
@@ -56,7 +56,7 @@ impl OperationWithDefaults for Create {
5656
_description: &StreamDescription,
5757
_session: Option<&mut ClientSession>,
5858
) -> OperationResponse<'static, Self::O> {
59-
sync! {{
59+
handle_response_sync! {{
6060
let response: WriteConcernOnlyBody = response.body()?;
6161
response.validate()
6262
}}

Diff for: src/operation/create_indexes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
Namespace,
1111
};
1212

13-
use super::{sync, OperationResponse, WriteConcernOnlyBody};
13+
use super::{handle_response_sync, OperationResponse, WriteConcernOnlyBody};
1414

1515
#[derive(Debug)]
1616
pub(crate) struct CreateIndexes {
@@ -77,7 +77,7 @@ impl OperationWithDefaults for CreateIndexes {
7777
_description: &'a StreamDescription,
7878
_session: Option<&mut ClientSession>,
7979
) -> OperationResponse<'static, Self::O> {
80-
sync! {{
80+
handle_response_sync! {{
8181
let response: WriteConcernOnlyBody = response.body()?;
8282
response.validate()?;
8383
let index_names = self.indexes.iter().filter_map(|i| i.get_name()).collect();

Diff for: src/operation/delete.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
ClientSession,
1717
};
1818

19-
use super::{sync, OperationResponse};
19+
use super::{handle_response_sync, OperationResponse};
2020

2121
#[derive(Debug)]
2222
pub(crate) struct Delete {
@@ -88,7 +88,7 @@ impl OperationWithDefaults for Delete {
8888
_description: &StreamDescription,
8989
_session: Option<&mut ClientSession>,
9090
) -> OperationResponse<'static, Self::O> {
91-
sync! {{
91+
handle_response_sync! {{
9292
let response: WriteResponseBody = response.body()?;
9393
response.validate().map_err(convert_bulk_errors)?;
9494

Diff for: src/operation/distinct.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
ClientSession,
1212
};
1313

14-
use super::{sync, OperationResponse};
14+
use super::{handle_response_sync, OperationResponse};
1515

1616
pub(crate) struct Distinct {
1717
ns: Namespace,
@@ -77,7 +77,7 @@ impl OperationWithDefaults for Distinct {
7777
_description: &StreamDescription,
7878
_session: Option<&mut ClientSession>,
7979
) -> OperationResponse<'static, Self::O> {
80-
sync! {{
80+
handle_response_sync! {{
8181
let response: Response = response.body()?;
8282
Ok(response.values)
8383
}}

Diff for: src/operation/drop_collection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
Namespace,
1616
};
1717

18-
use super::{sync, OperationResponse};
18+
use super::{handle_response_sync, OperationResponse};
1919

2020
#[derive(Debug)]
2121
pub(crate) struct DropCollection {
@@ -56,7 +56,7 @@ impl OperationWithDefaults for DropCollection {
5656
_description: &StreamDescription,
5757
_session: Option<&mut ClientSession>,
5858
) -> OperationResponse<'static, Self::O> {
59-
sync! {{
59+
handle_response_sync! {{
6060
let response: WriteConcernOnlyBody = response.body()?;
6161
response.validate()
6262
}}

Diff for: src/operation/drop_database.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
ClientSession,
1616
};
1717

18-
use super::{sync, OperationResponse};
18+
use super::{handle_response_sync, OperationResponse};
1919

2020
#[derive(Debug)]
2121
pub(crate) struct DropDatabase {
@@ -63,7 +63,7 @@ impl OperationWithDefaults for DropDatabase {
6363
_description: &StreamDescription,
6464
_session: Option<&mut ClientSession>,
6565
) -> OperationResponse<'static, Self::O> {
66-
sync! {{
66+
handle_response_sync! {{
6767
let response: WriteConcernOnlyBody = response.body()?;
6868
response.validate()
6969
}}

Diff for: src/operation/drop_indexes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
Namespace,
99
};
1010

11-
use super::{sync, OperationResponse};
11+
use super::{handle_response_sync, OperationResponse};
1212

1313
pub(crate) struct DropIndexes {
1414
ns: Namespace,
@@ -49,7 +49,7 @@ impl OperationWithDefaults for DropIndexes {
4949
_description: &StreamDescription,
5050
_session: Option<&mut ClientSession>,
5151
) -> OperationResponse<'static, Self::O> {
52-
sync! {{ Ok(()) }}
52+
handle_response_sync! {{ Ok(()) }}
5353
}
5454

5555
fn write_concern(&self) -> Option<&WriteConcern> {

Diff for: src/operation/find.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
Namespace,
1616
};
1717

18-
use super::{sync, OperationResponse};
18+
use super::{handle_response_sync, OperationResponse};
1919

2020
#[derive(Debug)]
2121
pub(crate) struct Find {
@@ -112,7 +112,7 @@ impl OperationWithDefaults for Find {
112112
description: &'a StreamDescription,
113113
_session: Option<&mut ClientSession>,
114114
) -> OperationResponse<'static, Self::O> {
115-
sync! {{
115+
handle_response_sync! {{
116116
let response: CursorBody = response.body()?;
117117

118118
// The comment should only be propagated to getMore calls on 4.4+.

Diff for: src/operation/find_and_modify.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
ClientSession,
3232
};
3333

34-
use super::{sync, OperationResponse};
34+
use super::{handle_response_sync, OperationResponse};
3535

3636
pub(crate) struct FindAndModify<'a, R, T: DeserializeOwned> {
3737
ns: Namespace,
@@ -147,7 +147,7 @@ impl<'a, R: Serialize, T: DeserializeOwned> OperationWithDefaults for FindAndMod
147147
_description: &StreamDescription,
148148
_session: Option<&mut ClientSession>,
149149
) -> OperationResponse<'static, Self::O> {
150-
sync! {{
150+
handle_response_sync! {{
151151
#[derive(Debug, Deserialize)]
152152
pub(crate) struct Response {
153153
value: RawBson,

Diff for: src/operation/get_more.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
Namespace,
1717
};
1818

19-
use super::{sync, OperationResponse};
19+
use super::{handle_response_sync, OperationResponse};
2020

2121
#[derive(Debug)]
2222
pub(crate) struct GetMore<'conn> {
@@ -90,7 +90,7 @@ impl<'conn> OperationWithDefaults for GetMore<'conn> {
9090
_description: &StreamDescription,
9191
_session: Option<&mut ClientSession>,
9292
) -> OperationResponse<'static, Self::O> {
93-
sync! {{
93+
handle_response_sync! {{
9494
let response: GetMoreResponseBody = response.body()?;
9595

9696
Ok(GetMoreResult {

Diff for: src/operation/insert.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ use crate::{
1616
Namespace,
1717
};
1818

19-
use super::{sync, OperationResponse, COMMAND_OVERHEAD_SIZE, MAX_ENCRYPTED_WRITE_SIZE};
19+
use super::{
20+
handle_response_sync,
21+
OperationResponse,
22+
COMMAND_OVERHEAD_SIZE,
23+
MAX_ENCRYPTED_WRITE_SIZE,
24+
};
2025

2126
#[derive(Debug)]
2227
pub(crate) struct Insert<'a, T> {
@@ -129,7 +134,7 @@ impl<'a, T: Serialize> OperationWithDefaults for Insert<'a, T> {
129134
_description: &'b StreamDescription,
130135
_session: Option<&mut ClientSession>,
131136
) -> OperationResponse<'static, Self::O> {
132-
sync! {{
137+
handle_response_sync! {{
133138
let response: WriteResponseBody = raw_response.body_utf8_lossy()?;
134139

135140
let mut map = HashMap::new();

Diff for: src/operation/list_collections.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
ClientSession,
99
};
1010

11-
use super::{sync, OperationResponse};
11+
use super::{handle_response_sync, OperationResponse};
1212

1313
#[derive(Debug)]
1414
pub(crate) struct ListCollections {
@@ -66,7 +66,7 @@ impl OperationWithDefaults for ListCollections {
6666
description: &'a StreamDescription,
6767
_session: Option<&mut ClientSession>,
6868
) -> OperationResponse<'static, Self::O> {
69-
sync! {{
69+
handle_response_sync! {{
7070
let response: CursorBody = raw_response.body()?;
7171
Ok(CursorSpecification::new(
7272
response.cursor,

Diff for: src/operation/list_databases.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
ClientSession,
1212
};
1313

14-
use super::{sync, OperationResponse};
14+
use super::{handle_response_sync, OperationResponse};
1515

1616
#[derive(Debug)]
1717
pub(crate) struct ListDatabases {
@@ -61,7 +61,7 @@ impl OperationWithDefaults for ListDatabases {
6161
_description: &StreamDescription,
6262
_session: Option<&mut ClientSession>,
6363
) -> OperationResponse<'static, Self::O> {
64-
sync! {{
64+
handle_response_sync! {{
6565
let response: Response = raw_response.body()?;
6666
Ok(response.databases)
6767
}}

Diff for: src/operation/list_indexes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
Namespace,
1111
};
1212

13-
use super::{sync, CursorBody, OperationResponse, Retryability};
13+
use super::{handle_response_sync, CursorBody, OperationResponse, Retryability};
1414

1515
pub(crate) struct ListIndexes {
1616
ns: Namespace,
@@ -51,7 +51,7 @@ impl OperationWithDefaults for ListIndexes {
5151
description: &'a StreamDescription,
5252
_session: Option<&mut ClientSession>,
5353
) -> OperationResponse<'static, Self::O> {
54-
sync! {{
54+
handle_response_sync! {{
5555
let response: CursorBody = raw_response.body()?;
5656
Ok(CursorSpecification::new(
5757
response.cursor,

0 commit comments

Comments
 (0)