Skip to content

Commit a47fc92

Browse files
authored
Refactor/rustfmt (#24)
* add rustfmt config file * apply formatting
1 parent 38c9aa6 commit a47fc92

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

.rustfmt.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version = "Two"
2+
use_field_init_shorthand = true
3+
imports_granularity="Module"
4+
wrap_comments = true
5+
use_try_shorthand = true
6+
format_code_in_doc_comments = true
7+
format_strings = true
8+
normalize_comments = true
9+
normalize_doc_attributes = true
10+
remove_nested_parens = true
11+
reorder_impl_items = true

src/info.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::FromRpcResponse;
2-
use crate::RequestError;
3-
use crate::RequestResult;
4-
use crate::TonicResult;
1+
use crate::{FromRpcResponse, RequestError, RequestResult, TonicResult};
52

63
mod pb {
74
tonic::include_proto!("mavsdk.rpc.info");
@@ -92,7 +89,7 @@ impl FromRpcResponse<pb::GetVersionResponse> for GetVersionResult {
9289
}
9390
}
9491

95-
#[doc = " Provide infomation about the hardware and/or software of a system."]
92+
/// Provide infomation about the hardware and/or software of a system.
9693
pub struct Info {
9794
service_client: pb::info_service_client::InfoServiceClient<tonic::transport::Channel>,
9895
}

src/mocap.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use crate::FromRpcResponse;
2-
use crate::RequestError;
3-
use crate::RequestResult;
4-
use crate::TonicResult;
1+
use crate::{FromRpcResponse, RequestError, RequestResult, TonicResult};
52

63
mod pb {
74
tonic::include_proto!("mavsdk.rpc.mocap");
@@ -10,7 +7,8 @@ mod pb {
107
/// Global position/attitude estimate from a vision source.
118
#[derive(Default, Clone, PartialEq, Debug)]
129
pub struct VisionPositionEstimate {
13-
/// PositionBody frame timestamp UNIX Epoch time (0 to use Backend timestamp)
10+
/// PositionBody frame timestamp UNIX Epoch time (0 to use Backend
11+
/// timestamp)
1412
pub time_usec: u64,
1513
/// Global position (m)
1614
pub position_body: PositionBody,
@@ -34,7 +32,8 @@ impl From<VisionPositionEstimate> for pb::VisionPositionEstimate {
3432
/// Motion capture attitude and position
3533
#[derive(Clone, PartialEq, Debug)]
3634
pub struct AttitudePosition {
37-
/// PositionBody frame timestamp UNIX Epoch time (0 to use Backend timestamp)
35+
/// PositionBody frame timestamp UNIX Epoch time (0 to use Backend
36+
/// timestamp)
3837
pub time_usec: u64,
3938
/// Attitude quaternion (w, x, y, z order, zero-rotation is 1, 0, 0, 0)
4039
pub q: Quaternion,
@@ -55,7 +54,8 @@ impl From<AttitudePosition> for pb::AttitudePositionMocap {
5554
}
5655
}
5756

58-
/// Odometry message to communicate odometry mocaprmation with an external interface.
57+
/// Odometry message to communicate odometry mocaprmation with an external
58+
/// interface.
5959
#[derive(Clone, PartialEq, Debug)]
6060
pub struct Odometry {
6161
/// Timestamp (0 to use Backend timestamp).
@@ -192,7 +192,6 @@ impl From<Covariance> for pb::Covariance {
192192
}
193193
}
194194

195-
///
196195
/// Quaternion type.
197196
///
198197
/// All rotations and axis systems follow the right-hand rule.
@@ -280,9 +279,9 @@ impl FromRpcResponse<pb::SetVisionPositionEstimateResponse> for SetVisionPositio
280279
}
281280
}
282281

283-
#[doc = " Motion Capture allow vehicles to navigate when a global"]
284-
#[doc = " position source is unavailable or unreliable"]
285-
#[doc = " (e.g. indoors, or when flying under a bridge. etc.)."]
282+
/// Motion Capture allow vehicles to navigate when a global
283+
/// position source is unavailable or unreliable
284+
/// (e.g. indoors, or when flying under a bridge. etc.).
286285
pub struct Mocap {
287286
service_client: pb::mocap_service_client::MocapServiceClient<tonic::transport::Channel>,
288287
}

src/telemetry.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::RequestError;
2-
use crate::RequestResult;
1+
use crate::{RequestError, RequestResult};
32
use futures_util::stream::{Stream, StreamExt};
43

54
mod pb {
@@ -12,8 +11,8 @@ pub enum MavFrame {
1211
/// Setpoint in body NED frame. This makes sense if all position control is
1312
/// externalized - e.g. useful to command 2 m/s^2 acceleration to the right.
1413
BodyNed = 8,
15-
/// Odometry local coordinate frame of data given by a vision estimation system,
16-
/// Z-down (x: north, y: east, z: down).
14+
/// Odometry local coordinate frame of data given by a vision estimation
15+
/// system, Z-down (x: north, y: east, z: down).
1716
VisionNed = 16,
1817
/// Odometry local coordinate frame of data given by an estimator running
1918
/// onboard the vehicle, Z-down (x: north, y: east, z: down).
@@ -27,7 +26,8 @@ pub struct Odometry {
2726
pub time_usec: u64,
2827
/// Coordinate frame of reference for the pose data.
2928
pub frame_id: MavFrame,
30-
/// Coordinate frame of reference for the velocity in free space (twist) data.
29+
/// Coordinate frame of reference for the velocity in free space (twist)
30+
/// data.
3131
pub child_frame_id: MavFrame,
3232
/// Position.
3333
pub position_body: PositionBody,
@@ -165,7 +165,6 @@ impl From<Covariance> for pb::Covariance {
165165
}
166166
}
167167

168-
///
169168
/// Quaternion type.
170169
///
171170
/// All rotations and axis systems follow the right-hand rule.
@@ -234,9 +233,9 @@ impl From<Error> for RequestError<Error> {
234233
}
235234
}
236235

237-
#[doc = ""]
238-
#[doc = " Allow users to get vehicle telemetry and state information"]
239-
#[doc = " (e.g. battery, GPS, RC connection, flight mode etc.) and set telemetry update rates."]
236+
/// Allow users to get vehicle telemetry and state information
237+
/// (e.g. battery, GPS, RC connection, flight mode etc.) and set telemetry
238+
/// update rates.
240239
pub struct Telemetry {
241240
service_client: pb::telemetry_service_client::TelemetryServiceClient<tonic::transport::Channel>,
242241
}

0 commit comments

Comments
 (0)