Skip to content

Commit

Permalink
Merge pull request #34 from gbbosak/main
Browse files Browse the repository at this point in the history
Fix Fuchsia build
  • Loading branch information
ephemeralriggs authored Dec 4, 2024
2 parents 13077eb + 77265cf commit 45f44af
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions mock-omaha-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,24 @@ use std::collections::HashMap;
use std::convert::Infallible;
use std::net::{Ipv4Addr, SocketAddr};
use std::sync::Arc;
#[cfg(feature = "tokio")]
#[cfg(not(target_os = "fuchsia"))]
use tokio::net::{TcpListener, TcpStream};
use url::Url;

#[cfg(feature = "tokio")]
#[cfg(not(target_os = "fuchsia"))]
use {
std::io,
std::pin::Pin,
std::task::{Context, Poll},
tokio::sync::Mutex,
tokio::task::JoinHandle,
};

#[cfg(all(not(fasync), not(target_os = "fuchsia")))]
use tokio::sync::Mutex;

#[cfg(fasync)]
use {fuchsia_async as fasync, fuchsia_async::Task, fuchsia_sync::Mutex};

#[cfg(all(fasync, not(target_os = "fuchsia")))]
use {
std::io,
std::pin::Pin,
std::task::{Context, Poll},
};

#[cfg(all(fasync, target_os = "fuchsia"))]
use fuchsia_async::net::TcpListener;

Expand Down Expand Up @@ -135,13 +130,13 @@ pub enum UpdateCheckAssertion {
}

/// Adapt [tokio::net::TcpStream] to work with hyper.
#[cfg(any(feature = "tokio", all(fasync, not(target_os = "fuchsia"))))]
#[cfg(not(target_os = "fuchsia"))]
#[derive(Debug)]
pub enum ConnectionStream {
Tcp(TcpStream),
}

#[cfg(any(feature = "tokio", all(fasync, not(target_os = "fuchsia"))))]
#[cfg(not(target_os = "fuchsia"))]
impl tokio::io::AsyncRead for ConnectionStream {
fn poll_read(
mut self: Pin<&mut Self>,
Expand All @@ -154,7 +149,7 @@ impl tokio::io::AsyncRead for ConnectionStream {
}
}

#[cfg(any(feature = "tokio", all(fasync, not(target_os = "fuchsia"))))]
#[cfg(not(target_os = "fuchsia"))]
impl tokio::io::AsyncWrite for ConnectionStream {
fn poll_write(
mut self: Pin<&mut Self>,
Expand All @@ -179,7 +174,10 @@ impl tokio::io::AsyncWrite for ConnectionStream {
}
}

#[cfg(not(target_os = "fuchsia"))]
struct TcpListenerStream(TcpListener);

#[cfg(not(target_os = "fuchsia"))]
impl Stream for TcpListenerStream {
type Item = Result<TcpStream, std::io::Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand Down Expand Up @@ -307,7 +305,7 @@ impl OmahaServer {

let server = async move {
Server::builder(from_stream(
listener.incoming().map_ok(ConnectionStream::Tcp),
TcpListenerStream(listener).map_ok(ConnectionStream::Tcp),
))
.executor(fuchsia_hyper::Executor)
.serve(make_svc)
Expand Down

0 comments on commit 45f44af

Please sign in to comment.