Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy CI a little #62

Merged
merged 5 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clippy.toml

This file was deleted.

39 changes: 9 additions & 30 deletions .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.56
rust: 1.65.0
- build: stable
os: ubuntu-latest
rust: stable
Expand All @@ -36,16 +36,11 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: check
args: --all-targets
- run: cargo check --all-targets

fmt:
name: format
Expand All @@ -54,16 +49,10 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
override: true
profile: minimal
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- run: cargo fmt -- --check

clippy:
name: lint
Expand All @@ -72,16 +61,13 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
override: true
profile: minimal
components: clippy, rustfmt
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --tests --examples
args: --all-targets

docs:
name: docs
Expand All @@ -90,12 +76,5 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps
- uses: dtolnay/rust-toolchain@stable
- run: cargo doc --no-deps
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "libmavsdk"
version = "0.1.0"
authors = ["Ildar Sadykov <[email protected]>"]
edition = "2021"
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
8 changes: 3 additions & 5 deletions examples/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1);
}

let url = args.get(0).cloned();
let url = args.first().cloned();

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

let version = system.info.get_version().await?;

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

Ok(())
}
2 changes: 1 addition & 1 deletion examples/mocap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1);
}

let url = args.get(0).cloned();
let url = args.first().cloned();

let mut system = System::connect(url).await?;

Expand Down
9 changes: 6 additions & 3 deletions examples/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
std::process::exit(1);
}

let url = args.get(0).cloned();
let url = args.first().cloned();

let mut system = System::connect(url).await?;
let mut stream_odometry = System::connect(url)
.await?
.telemetry
.subscribe_odometry()
.await?;

let mut stream_odometry = system.telemetry.subscribe_odometry().await?;
while let Some(odometry) = stream_odometry.next().await {
println!("Received: {:?}", odometry?);
}
Expand Down
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 })
}
}
Loading