Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Nov 4, 2023
1 parent 73aee73 commit 6e0425f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
include:
- build: msrv
os: ubuntu-latest
rust: 1.63.0
rust: 1.65.0
- build: stable
os: ubuntu-latest
rust: stable
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libmavsdk"
version = "0.1.0"
authors = ["Ildar Sadykov <[email protected]>"]
edition = "2021"
rust-version = "1.63.0"
rust-version = "1.65.0"

[dependencies]
tonic = "0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const PLUGINS: &[&str] = &[

fn main() -> std::io::Result<()> {
for plugin in PLUGINS {
let proto_path = format!("{0}/{1}/{1}.proto", PROTO_INCLUDE_PATH, plugin);
let proto_path = format!("{PROTO_INCLUDE_PATH}/{plugin}/{plugin}.proto");

tonic_build::configure()
.build_server(false)
Expand Down
2 changes: 1 addition & 1 deletion examples/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let version = System::connect(url).await?.info.get_version().await?;

println!("Version received: {:?}", version);
println!("Version received: {version:?}");

Ok(())
}
14 changes: 7 additions & 7 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod pb {
tonic::include_proto!("mavsdk.rpc.info");
}

#[derive(PartialEq, Clone, Default, Debug)]
#[derive(PartialEq, Eq, Clone, Default, Debug)]
pub struct Version {
/// Flight software major version
pub flight_sw_major: i32,
Expand All @@ -28,7 +28,7 @@ pub struct Version {

impl From<&pb::Version> for Version {
fn from(rpc_version: &pb::Version) -> Self {
Version {
Self {
flight_sw_major: rpc_version.flight_sw_major,
flight_sw_minor: rpc_version.flight_sw_minor,
flight_sw_patch: rpc_version.flight_sw_patch,
Expand All @@ -42,7 +42,7 @@ impl From<&pb::Version> for Version {
}
}

#[derive(PartialEq, Clone, Debug, thiserror::Error)]
#[derive(PartialEq, Eq, Clone, Debug, thiserror::Error)]
pub enum Error {
#[error("Unknown error: {0}")]
Unknown(String),
Expand Down Expand Up @@ -72,8 +72,8 @@ impl FromRpcResponse<pb::GetVersionResponse> for GetVersionResult {
.ok_or_else(|| Error::Unknown("Unsupported InfoResult.result value".into()))?;

match info_result {
pb::info_result::Result::Success => match get_version_response.version {
Some(ref rpc_version) => Ok(Version::from(rpc_version)),
pb::info_result::Result::Success => match &get_version_response.version {
Some(rpc_version) => Ok(Version::from(rpc_version)),
None => Err(Error::Unknown("Version does not received".into()).into()),
},
pb::info_result::Result::Unknown => {
Expand Down Expand Up @@ -104,8 +104,8 @@ impl Info {

#[tonic::async_trait]
impl crate::Connect for Info {
async fn connect(url: String) -> std::result::Result<Info, tonic::transport::Error> {
Ok(Info {
async fn connect(url: String) -> std::result::Result<Self, tonic::transport::Error> {
Ok(Self {
service_client: pb::info_service_client::InfoServiceClient::connect(url).await?,
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct System {
}

impl System {
pub async fn connect(url: Option<String>) -> Result<System, tonic::transport::Error> {
pub async fn connect(url: Option<String>) -> Result<Self, tonic::transport::Error> {
let url = url.unwrap_or_else(|| String::from("http://0.0.0.0:50051"));

let (mocap, info, telemetry) = try_join3(
Expand All @@ -41,7 +41,7 @@ impl System {
)
.await?;

Ok(System {
Ok(Self {
mocap,
info,
telemetry,
Expand Down
6 changes: 3 additions & 3 deletions src/mocap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl From<Quaternion> for pb::Quaternion {
}
}

#[derive(PartialEq, Clone, Debug, thiserror::Error)]
#[derive(PartialEq, Eq, Clone, Debug, thiserror::Error)]
pub enum Error {
/// Unknown error
#[error("Unknown error: {0}")]
Expand Down Expand Up @@ -304,8 +304,8 @@ impl Mocap {

#[tonic::async_trait]
impl crate::Connect for Mocap {
async fn connect(url: String) -> std::result::Result<Mocap, tonic::transport::Error> {
Ok(Mocap {
async fn connect(url: String) -> std::result::Result<Self, tonic::transport::Error> {
Ok(Self {
service_client: pb::mocap_service_client::MocapServiceClient::connect(url).await?,
})
}
Expand Down
12 changes: 6 additions & 6 deletions src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct PositionBody {

impl From<&pb::PositionBody> for PositionBody {
fn from(rpc_position_body: &pb::PositionBody) -> Self {
PositionBody {
Self {
x_m: rpc_position_body.x_m,
y_m: rpc_position_body.y_m,
z_m: rpc_position_body.z_m,
Expand Down Expand Up @@ -108,7 +108,7 @@ pub struct AngularVelocityBody {

impl From<&pb::AngularVelocityBody> for AngularVelocityBody {
fn from(rpc_angular_velocity_body: &pb::AngularVelocityBody) -> Self {
AngularVelocityBody {
Self {
roll_rad_s: rpc_angular_velocity_body.roll_rad_s,
pitch_rad_s: rpc_angular_velocity_body.pitch_rad_s,
yaw_rad_s: rpc_angular_velocity_body.yaw_rad_s,
Expand Down Expand Up @@ -136,8 +136,8 @@ pub struct Covariance {
}

impl From<pb::Odometry> for Odometry {
fn from(rpc_odometry: pb::Odometry) -> Odometry {
Odometry {
fn from(rpc_odometry: pb::Odometry) -> Self {
Self {
time_usec: 0,
frame_id: MavFrame::from_i32(rpc_odometry.frame_id).unwrap(),
child_frame_id: MavFrame::from_i32(rpc_odometry.child_frame_id).unwrap(),
Expand Down Expand Up @@ -266,10 +266,10 @@ pub type OdometryResult = RequestResult<Odometry, Error>;

#[tonic::async_trait]
impl crate::Connect for Telemetry {
async fn connect(url: String) -> std::result::Result<Telemetry, tonic::transport::Error> {
async fn connect(url: String) -> std::result::Result<Self, tonic::transport::Error> {
let service_client =
pb::telemetry_service_client::TelemetryServiceClient::connect(url).await?;

Ok(Telemetry { service_client })
Ok(Self { service_client })
}
}

0 comments on commit 6e0425f

Please sign in to comment.