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

Remove custom NeverOkResult trait and instead use new Rust 1.82 matching #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- os: ubuntu-latest
# MSRV. Not considered breaking when this has to be bumped.
# But update `rust-version` in `Cargo.toml`
rust: 1.80.0
rust: 1.82.0
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
description = "Tunnel UDP traffic inside a TCP stream. Each datagram is prefixed with a 16 bit unsigned integer containing the length"
repository = "https://github.com/mullvad/udp-over-tcp"
edition = "2021"
rust-version = "1.80.0"
rust-version = "1.82.0"
publish = false

[[bin]]
Expand Down
6 changes: 2 additions & 4 deletions src/bin/tcp2udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use err_context::ErrorExt as _;
use std::num::NonZeroU8;

use udp_over_tcp::{tcp2udp, NeverOkResult};
use udp_over_tcp::tcp2udp;

#[derive(Debug, Parser)]
#[command(
Expand All @@ -30,9 +30,7 @@ fn main() {

let runtime = create_runtime(options.threads);

let error = runtime
.block_on(tcp2udp::run(options.tcp2udp_options))
.into_error();
let Err(error) = runtime.block_on(tcp2udp::run(options.tcp2udp_options));
log::error!("Error: {}", error.display("\nCaused by: "));
std::process::exit(1);
}
Expand Down
3 changes: 1 addition & 2 deletions src/forward_traffic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::NeverOkResult;
use err_context::BoxedErrorExt as _;
use err_context::ResultExt as _;
use futures::future::select;
Expand Down Expand Up @@ -41,7 +40,7 @@ pub async fn process_udp_over_tcp(
}
};
let udp2tcp = async move {
let error = process_udp2tcp(udp_in, tcp_out).await.into_error();
let Err(error) = process_udp2tcp(udp_in, tcp_out).await;
log::error!("Error: {}", error.display("\nCaused by: "));
};

Expand Down
12 changes: 0 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,3 @@ pub use tcp_options::{ApplyTcpOptionsError, ApplyTcpOptionsErrorKind, TcpOptions

/// Size of the header (in bytes) that is prepended to each datagram in the TCP stream.
pub use forward_traffic::HEADER_LEN;

/// Helper trait for `Result<Infallible, E>` types. Allows getting the `E` value
/// in a way that is guaranteed to not panic.
pub trait NeverOkResult<E> {
fn into_error(self) -> E;
}

impl<E> NeverOkResult<E> for Result<std::convert::Infallible, E> {
fn into_error(self) -> E {
self.expect_err("Result<Infallible, _> can't be Ok variant")
}
}
Loading