Skip to content

Commit f221b4b

Browse files
Dorian Eikenbergrageagainsthepc
authored andcommitted
Update rust deps and fix clippy lints
1 parent 924503f commit f221b4b

File tree

6 files changed

+21
-72
lines changed

6 files changed

+21
-72
lines changed

vmicore/rust_src/Cargo.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@ edition = "2021"
77
crate-type = ["lib", "staticlib"]
88

99
[dependencies]
10-
tonic = "0.11.0"
11-
prost = "0.12.3"
12-
prost-types = "0.12.3"
13-
tokio = { version = "1.22", features = ["macros", "rt-multi-thread", "net"] }
10+
tonic = "0.12.3"
11+
prost = "0.13.3"
12+
prost-types = "0.13.3"
13+
tokio = { version = "1.41", features = ["macros", "rt-multi-thread", "net"] }
14+
tokio-stream = "0.1.16"
15+
hyper-util = "0.1.10"
1416
cxx = "1.0"
1517
triggered = "0.1.2"
16-
async-std = "1.12"
17-
async-stream = "0.3.3"
18-
futures-core = "0.3.25"
19-
chrono = "0.4.23"
18+
async-std = "1.13"
19+
async-stream = "0.3.6"
20+
futures-core = "0.3.31"
21+
chrono = "0.4.38"
2022
thiserror = "1"
21-
futures = { version = "0.3", default-features = false, features = ["alloc"] }
2223

2324
[dev-dependencies]
24-
tower = "0.4.13"
25-
ctrlc = "3.4.0"
25+
tower = "0.5.1"
26+
ctrlc = "3.4.5"
2627

2728
[build-dependencies]
28-
tonic-build = "0.11.0"
29+
tonic-build = "0.12.3"

vmicore/rust_src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() -> Result<(), Box<dyn std::error::Error>> {
2-
tonic_build::configure().build_client(true).compile(
2+
tonic_build::configure().build_client(true).compile_protos(
33
&[
44
"./protos/pkg/logging/service/v1/log_svc.proto",
55
"./protos/pkg/vmi/v1/vmi_svc.proto",

vmicore/rust_src/examples/grpc_client.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::error::Error;
22

3+
use hyper_util::rt::TokioIo;
34
use tokio::{net::UnixStream, try_join};
45
use tonic::{
56
transport::{Channel, Endpoint, Uri},
@@ -14,6 +15,8 @@ use rust_grpc_server::pkg::logging::{
1415
};
1516
use rust_grpc_server::pkg::vmi::v1::{vmi_service_client::VmiServiceClient, ListenForEventsRequest};
1617

18+
const UNIX_SOCKET_ADDR: &str = "/tmp/vmi.sock";
19+
1720
async fn log_client(channel: Channel, trigger: Trigger, listener: Listener) -> Result<(), Box<dyn Error>> {
1821
let mut client = LogServiceClient::new(channel);
1922

@@ -59,13 +62,11 @@ async fn vmi_client(channel: Channel, trigger: Trigger, listener: Listener) -> R
5962

6063
#[tokio::main]
6164
async fn main() -> Result<(), Box<dyn Error>> {
62-
let addr = "/tmp/vmi.sock";
63-
6465
// Url not used
6566
let channel = Endpoint::try_from("http://[::]:50051")?
66-
.connect_with_connector(service_fn(move |_: Uri| {
67+
.connect_with_connector(service_fn(|_: Uri| async {
6768
// Connect to a Uds socket
68-
UnixStream::connect(addr)
69+
Ok::<_, std::io::Error>(TokioIo::new(UnixStream::connect(UNIX_SOCKET_ADDR).await?))
6970
}))
7071
.await?;
7172

vmicore/rust_src/src/grpc_server.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use crate::pkg::vmi::v1::{
1313
use async_std::channel::{unbounded, Receiver, Sender};
1414
use async_std::task;
1515
use cxx::CxxVector;
16-
use futures::TryFutureExt;
1716
use std::error::Error;
1817
use std::fmt::Debug;
1918
use std::pin::Pin;
2019
use std::result;
2120
use std::time::SystemTime;
2221
use tokio::net::UnixListener;
22+
use tokio_stream::wrappers::UnixListenerStream;
2323
use tonic::transport::Server;
2424
use tonic::{Status, Streaming};
2525

@@ -78,11 +78,7 @@ impl GRPCServer {
7878
}
7979
let uds = UnixListener::bind(addr_ref)?;
8080

81-
async_stream::stream! {
82-
loop {
83-
yield uds.accept().map_ok(|(st, _)| crate::unix_socket::UnixStream(st)).await;
84-
}
85-
}
81+
UnixListenerStream::new(uds)
8682
};
8783

8884
Server::builder()

vmicore/rust_src/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod grpc_logger;
55
pub mod grpc_server;
66
mod grpc_vmi_service;
77
mod logging;
8-
mod unix_socket;
98

109
pub mod pkg {
1110
#![allow(clippy::derive_partial_eq_without_eq)]

vmicore/rust_src/src/unix_socket.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)