mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-07-14 10:49:32 -04:00
Upgrade to Rust 1.86.0
This commit is contained in:
parent
452e4d0ab8
commit
13d5ca65d6
8 changed files with 502 additions and 437 deletions
511
Cargo.lock
generated
511
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@ repository = "https://gitlab.com/veilid/veilid"
|
|||
authors = ["Veilid Team <contact@veilid.com>"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.81.0"
|
||||
rust-version = "1.86.0"
|
||||
|
||||
[patch.crates-io]
|
||||
cursive = { git = "https://gitlab.com/veilid/cursive.git" }
|
||||
|
|
|
@ -18,7 +18,7 @@ ENV ZIG_VERSION=0.13.0
|
|||
ENV CMAKE_VERSION_MINOR=3.30
|
||||
ENV CMAKE_VERSION_PATCH=3.30.1
|
||||
ENV WASM_BINDGEN_CLI_VERSION=0.2.100
|
||||
ENV RUST_VERSION=1.81.0
|
||||
ENV RUST_VERSION=1.86.0
|
||||
ENV RUSTUP_HOME=/usr/local/rustup
|
||||
ENV RUSTUP_DIST_SERVER=https://static.rust-lang.org
|
||||
ENV CARGO_HOME=/usr/local/cargo
|
||||
|
|
|
@ -198,7 +198,7 @@ impl IGDManager {
|
|||
|
||||
// Map any port
|
||||
let desc = this.get_description(protocol_type, local_port);
|
||||
let mapped_port = match gw.add_any_port(convert_protocol_type(protocol_type), SocketAddr::new(local_ip, local_port), (UPNP_MAPPING_LIFETIME_MS + 999) / 1000, &desc) {
|
||||
let mapped_port = match gw.add_any_port(convert_protocol_type(protocol_type), SocketAddr::new(local_ip, local_port), UPNP_MAPPING_LIFETIME_MS.div_ceil(1000), &desc) {
|
||||
Ok(mapped_port) => mapped_port,
|
||||
Err(e) => {
|
||||
// Failed to map external port
|
||||
|
@ -295,7 +295,7 @@ impl IGDManager {
|
|||
match gw.add_any_port(
|
||||
convert_protocol_type(k.protocol_type),
|
||||
SocketAddr::new(local_ip, k.local_port),
|
||||
(UPNP_MAPPING_LIFETIME_MS + 999) / 1000,
|
||||
UPNP_MAPPING_LIFETIME_MS.div_ceil(1000),
|
||||
&desc,
|
||||
) {
|
||||
Ok(mapped_port) => {
|
||||
|
@ -343,7 +343,7 @@ impl IGDManager {
|
|||
convert_protocol_type(k.protocol_type),
|
||||
v.mapped_port,
|
||||
SocketAddr::new(local_ip, k.local_port),
|
||||
(UPNP_MAPPING_LIFETIME_MS + 999) / 1000,
|
||||
UPNP_MAPPING_LIFETIME_MS.div_ceil(1000),
|
||||
&desc,
|
||||
) {
|
||||
Ok(()) => {
|
||||
|
|
|
@ -138,7 +138,7 @@ pub fn capability_fanout_node_info_filter(caps: Vec<Capability>) -> FanoutNodeIn
|
|||
/// * 'node_count' - the number of nodes to keep in the closest_nodes set
|
||||
/// * 'fanout' - the number of concurrent calls being processed at the same time
|
||||
/// * 'consensus_count' - the number of nodes in the processed queue that need to be in the
|
||||
/// 'Accepted' state before we terminate the fanout early.
|
||||
/// 'Accepted' state before we terminate the fanout early.
|
||||
///
|
||||
/// The algorithm returns early if 'check_done' returns some value, or if an error is found during the process.
|
||||
/// If the algorithm times out, a Timeout result is returned, however operations will still have been performed and a
|
||||
|
|
|
@ -830,7 +830,7 @@ impl VeilidConfig {
|
|||
/// specified to override this location
|
||||
///
|
||||
/// * `program_name` - Pick a program name and do not change it from release to release,
|
||||
/// see `VeilidConfig::program_name` for details.
|
||||
/// see `VeilidConfig::program_name` for details.
|
||||
/// * `organization_name` - Similar to program_name, but for the organization publishing this app
|
||||
/// * `qualifier` - Suffix for the application bundle name
|
||||
/// * `storage_directory` - Override for the path where veilid-core stores its content
|
||||
|
|
|
@ -1,205 +1,205 @@
|
|||
use crate::*;
|
||||
use futures_util::stream::FuturesUnordered;
|
||||
use futures_util::AsyncRead as FuturesAsyncRead;
|
||||
use futures_util::AsyncWrite as FuturesAsyncWrite;
|
||||
use futures_util::Stream;
|
||||
use std::path::PathBuf;
|
||||
use std::{io, path::Path};
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use tokio::net::windows::named_pipe::{
|
||||
ClientOptions, NamedPipeClient, NamedPipeServer, ServerOptions,
|
||||
};
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
enum IpcStreamInternal {
|
||||
Client(NamedPipeClient),
|
||||
Server(NamedPipeServer),
|
||||
}
|
||||
|
||||
pub struct IpcStream {
|
||||
internal: IpcStreamInternal,
|
||||
}
|
||||
|
||||
impl IpcStream {
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn connect<P: AsRef<Path>>(path: P) -> io::Result<IpcStream> {
|
||||
Ok(IpcStream {
|
||||
internal: IpcStreamInternal::Client(
|
||||
ClientOptions::new().open(path.as_ref().to_path_buf().as_os_str())?,
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl FuturesAsyncRead for IpcStream {
|
||||
fn poll_read(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
buf: &mut [u8],
|
||||
) -> std::task::Poll<io::Result<usize>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
let mut rb = ReadBuf::new(buf);
|
||||
match <NamedPipeClient as AsyncRead>::poll_read(
|
||||
std::pin::Pin::new(client),
|
||||
cx,
|
||||
&mut rb,
|
||||
) {
|
||||
std::task::Poll::Ready(r) => {
|
||||
std::task::Poll::Ready(r.map(|_| rb.filled().len()))
|
||||
}
|
||||
std::task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
let mut rb = ReadBuf::new(buf);
|
||||
match <NamedPipeServer as AsyncRead>::poll_read(
|
||||
std::pin::Pin::new(server),
|
||||
cx,
|
||||
&mut rb,
|
||||
) {
|
||||
std::task::Poll::Ready(r) => {
|
||||
std::task::Poll::Ready(r.map(|_| rb.filled().len()))
|
||||
}
|
||||
std::task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FuturesAsyncWrite for IpcStream {
|
||||
fn poll_write(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> std::task::Poll<io::Result<usize>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_write(std::pin::Pin::new(client), cx, buf)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_write(std::pin::Pin::new(server), cx, buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<io::Result<()>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_flush(std::pin::Pin::new(client), cx)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_flush(std::pin::Pin::new(server), cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<io::Result<()>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_shutdown(std::pin::Pin::new(client), cx)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_shutdown(std::pin::Pin::new(server), cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct IpcIncoming<'a> {
|
||||
listener: IpcListener,
|
||||
unord: FuturesUnordered<PinBoxFutureStatic<io::Result<IpcStream>>>,
|
||||
phantom: std::marker::PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl Stream for IpcIncoming<'_> {
|
||||
type Item = io::Result<IpcStream>;
|
||||
|
||||
fn poll_next<'a>(
|
||||
mut self: std::pin::Pin<&'a mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Option<Self::Item>> {
|
||||
if self.unord.is_empty() {
|
||||
self.unord.push(Box::pin(self.listener.accept()));
|
||||
}
|
||||
match Pin::new(&mut self.unord).poll_next(cx) {
|
||||
task::Poll::Ready(ro) => {
|
||||
self.unord.push(Box::pin(self.listener.accept()));
|
||||
std::task::Poll::Ready(ro)
|
||||
}
|
||||
task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct IpcListener {
|
||||
path: Option<PathBuf>,
|
||||
internal: Option<Mutex<Option<NamedPipeServer>>>,
|
||||
}
|
||||
|
||||
impl IpcListener {
|
||||
/// Creates a new `IpcListener` bound to the specified path.
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn bind<P: AsRef<Path>>(path: P) -> io::Result<Self> {
|
||||
let path = path.as_ref().to_path_buf();
|
||||
let server = ServerOptions::new()
|
||||
.first_pipe_instance(true)
|
||||
.create(&path)?;
|
||||
Ok(Self {
|
||||
path: Some(path),
|
||||
internal: Some(Mutex::new(Some(server))),
|
||||
})
|
||||
}
|
||||
|
||||
/// Accepts a new incoming connection to this listener.
|
||||
#[must_use]
|
||||
pub fn accept(&self) -> PinBoxFutureStatic<io::Result<IpcStream>> {
|
||||
if self.path.is_none() {
|
||||
return Box::pin(std::future::ready(Err(io::Error::from(
|
||||
io::ErrorKind::NotConnected,
|
||||
))));
|
||||
}
|
||||
let internal = self.internal.as_ref().unwrap();
|
||||
let mut opt_server = internal.lock();
|
||||
let server = opt_server.take().unwrap();
|
||||
let path = self.path.clone().unwrap();
|
||||
*opt_server = match ServerOptions::new().create(path) {
|
||||
Ok(v) => Some(v),
|
||||
Err(e) => return Box::pin(std::future::ready(Err(e))),
|
||||
};
|
||||
|
||||
Box::pin(async move {
|
||||
server.connect().await?;
|
||||
|
||||
Ok(IpcStream {
|
||||
internal: IpcStreamInternal::Server(server),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns a stream of incoming connections.
|
||||
pub fn incoming(&mut self) -> io::Result<IpcIncoming<'_>> {
|
||||
if self.path.is_none() {
|
||||
return Err(io::Error::from(io::ErrorKind::NotConnected));
|
||||
}
|
||||
Ok(IpcIncoming {
|
||||
listener: IpcListener {
|
||||
path: self.path.take(),
|
||||
internal: self.internal.take(),
|
||||
},
|
||||
unord: FuturesUnordered::new(),
|
||||
phantom: std::marker::PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
use crate::*;
|
||||
use futures_util::stream::FuturesUnordered;
|
||||
use futures_util::AsyncRead as FuturesAsyncRead;
|
||||
use futures_util::AsyncWrite as FuturesAsyncWrite;
|
||||
use futures_util::Stream;
|
||||
use std::path::PathBuf;
|
||||
use std::{io, path::Path};
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use tokio::net::windows::named_pipe::{
|
||||
ClientOptions, NamedPipeClient, NamedPipeServer, ServerOptions,
|
||||
};
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
enum IpcStreamInternal {
|
||||
Client(NamedPipeClient),
|
||||
Server(NamedPipeServer),
|
||||
}
|
||||
|
||||
pub struct IpcStream {
|
||||
internal: IpcStreamInternal,
|
||||
}
|
||||
|
||||
impl IpcStream {
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn connect<P: AsRef<Path>>(path: P) -> io::Result<IpcStream> {
|
||||
Ok(IpcStream {
|
||||
internal: IpcStreamInternal::Client(
|
||||
ClientOptions::new().open(path.as_ref().to_path_buf().as_os_str())?,
|
||||
),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl FuturesAsyncRead for IpcStream {
|
||||
fn poll_read(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
buf: &mut [u8],
|
||||
) -> std::task::Poll<io::Result<usize>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
let mut rb = ReadBuf::new(buf);
|
||||
match <NamedPipeClient as AsyncRead>::poll_read(
|
||||
std::pin::Pin::new(client),
|
||||
cx,
|
||||
&mut rb,
|
||||
) {
|
||||
std::task::Poll::Ready(r) => {
|
||||
std::task::Poll::Ready(r.map(|_| rb.filled().len()))
|
||||
}
|
||||
std::task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
let mut rb = ReadBuf::new(buf);
|
||||
match <NamedPipeServer as AsyncRead>::poll_read(
|
||||
std::pin::Pin::new(server),
|
||||
cx,
|
||||
&mut rb,
|
||||
) {
|
||||
std::task::Poll::Ready(r) => {
|
||||
std::task::Poll::Ready(r.map(|_| rb.filled().len()))
|
||||
}
|
||||
std::task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FuturesAsyncWrite for IpcStream {
|
||||
fn poll_write(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
buf: &[u8],
|
||||
) -> std::task::Poll<io::Result<usize>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_write(std::pin::Pin::new(client), cx, buf)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_write(std::pin::Pin::new(server), cx, buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_flush(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<io::Result<()>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_flush(std::pin::Pin::new(client), cx)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_flush(std::pin::Pin::new(server), cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_close(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<io::Result<()>> {
|
||||
match &mut self.internal {
|
||||
IpcStreamInternal::Client(client) => {
|
||||
<NamedPipeClient as AsyncWrite>::poll_shutdown(std::pin::Pin::new(client), cx)
|
||||
}
|
||||
IpcStreamInternal::Server(server) => {
|
||||
<NamedPipeServer as AsyncWrite>::poll_shutdown(std::pin::Pin::new(server), cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct IpcIncoming<'a> {
|
||||
listener: IpcListener,
|
||||
unord: FuturesUnordered<PinBoxFutureStatic<io::Result<IpcStream>>>,
|
||||
phantom: std::marker::PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl Stream for IpcIncoming<'_> {
|
||||
type Item = io::Result<IpcStream>;
|
||||
|
||||
fn poll_next(
|
||||
mut self: std::pin::Pin<&mut Self>,
|
||||
cx: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Option<Self::Item>> {
|
||||
if self.unord.is_empty() {
|
||||
self.unord.push(Box::pin(self.listener.accept()));
|
||||
}
|
||||
match Pin::new(&mut self.unord).poll_next(cx) {
|
||||
task::Poll::Ready(ro) => {
|
||||
self.unord.push(Box::pin(self.listener.accept()));
|
||||
std::task::Poll::Ready(ro)
|
||||
}
|
||||
task::Poll::Pending => std::task::Poll::Pending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
pub struct IpcListener {
|
||||
path: Option<PathBuf>,
|
||||
internal: Option<Mutex<Option<NamedPipeServer>>>,
|
||||
}
|
||||
|
||||
impl IpcListener {
|
||||
/// Creates a new `IpcListener` bound to the specified path.
|
||||
#[expect(clippy::unused_async)]
|
||||
pub async fn bind<P: AsRef<Path>>(path: P) -> io::Result<Self> {
|
||||
let path = path.as_ref().to_path_buf();
|
||||
let server = ServerOptions::new()
|
||||
.first_pipe_instance(true)
|
||||
.create(&path)?;
|
||||
Ok(Self {
|
||||
path: Some(path),
|
||||
internal: Some(Mutex::new(Some(server))),
|
||||
})
|
||||
}
|
||||
|
||||
/// Accepts a new incoming connection to this listener.
|
||||
#[must_use]
|
||||
pub fn accept(&self) -> PinBoxFutureStatic<io::Result<IpcStream>> {
|
||||
if self.path.is_none() {
|
||||
return Box::pin(std::future::ready(Err(io::Error::from(
|
||||
io::ErrorKind::NotConnected,
|
||||
))));
|
||||
}
|
||||
let internal = self.internal.as_ref().unwrap();
|
||||
let mut opt_server = internal.lock();
|
||||
let server = opt_server.take().unwrap();
|
||||
let path = self.path.clone().unwrap();
|
||||
*opt_server = match ServerOptions::new().create(path) {
|
||||
Ok(v) => Some(v),
|
||||
Err(e) => return Box::pin(std::future::ready(Err(e))),
|
||||
};
|
||||
|
||||
Box::pin(async move {
|
||||
server.connect().await?;
|
||||
|
||||
Ok(IpcStream {
|
||||
internal: IpcStreamInternal::Server(server),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns a stream of incoming connections.
|
||||
pub fn incoming(&mut self) -> io::Result<IpcIncoming<'_>> {
|
||||
if self.path.is_none() {
|
||||
return Err(io::Error::from(io::ErrorKind::NotConnected));
|
||||
}
|
||||
Ok(IpcIncoming {
|
||||
listener: IpcListener {
|
||||
path: self.path.take(),
|
||||
internal: self.internal.take(),
|
||||
},
|
||||
unord: FuturesUnordered::new(),
|
||||
phantom: std::marker::PhantomData,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ impl PlatformSupportWindows {
|
|||
for (n, netmask_elt) in netmask
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.take((prefix.PrefixLength as usize + 7) / 8)
|
||||
.take((prefix.PrefixLength as usize).div_ceil(8))
|
||||
{
|
||||
let x_byte = ipv4_addr.octets()[n];
|
||||
let y_byte = a.octets()[n];
|
||||
|
@ -140,7 +140,7 @@ impl PlatformSupportWindows {
|
|||
for (n, netmask_elt) in netmask
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.take((prefix.PrefixLength as usize + 15) / 16)
|
||||
.take((prefix.PrefixLength as usize).div_ceil(16))
|
||||
{
|
||||
let x_word = ipv6_addr.segments()[n];
|
||||
let y_word = a.segments()[n];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue