//! A mock [`server_fn::client::Client`] implementation used when no client feature is enabled. use std::future::Future; use futures_util::Stream; use server_fn::{request::ClientReq, response::ClientRes}; /// A placeholder [`server_fn::client::Client`] used when no client feature is enabled. The /// [`server_fn::client::browser::BrowserClient`] is used on web clients, and [`server_fn::client::reqwest::ReqwestClient`] /// is used on native clients #[non_exhaustive] pub struct MockServerFnClient {} impl Default for MockServerFnClient { fn default() -> Self { Self::new() } } impl MockServerFnClient { /// Create a new mock server function client pub fn new() -> Self { Self {} } } impl server_fn::client::Client for MockServerFnClient { type Request = MockServerFnClientRequest; type Response = MockServerFnClientResponse; async fn send(_: Self::Request) -> Result { unimplemented!() } #[allow(unreachable_code)] async fn open_websocket( _: &str, ) -> Result< ( impl Stream> + std::marker::Send + 'static, impl futures_util::Sink + std::marker::Send + 'static, ), Error, > { unimplemented!() as Result< ( futures_util::stream::Once>, futures_util::sink::Drain, ), _, > } fn spawn(_: impl Future + Send + 'static) { unimplemented!() } } /// A placeholder [`ClientReq`] used when no client feature is enabled. #[non_exhaustive] pub struct MockServerFnClientRequest {} impl ClientReq for MockServerFnClientRequest { type FormData = (); fn try_new_req_query(_: &str, _: &str, _: &str, _: &str, _: http::Method) -> Result { unimplemented!() } fn try_new_req_text(_: &str, _: &str, _: &str, _: String, _: http::Method) -> Result { unimplemented!() } fn try_new_req_bytes( _: &str, _: &str, _: &str, _: bytes::Bytes, _: http::Method, ) -> Result { unimplemented!() } fn try_new_req_form_data( _: &str, _: &str, _: &str, _: Self::FormData, _: http::Method, ) -> Result { unimplemented!() } fn try_new_req_multipart( _: &str, _: &str, _: Self::FormData, _: http::Method, ) -> Result { unimplemented!() } fn try_new_req_streaming( _: &str, _: &str, _: &str, _: impl Stream + Send + 'static, _: http::Method, ) -> Result { unimplemented!() } } /// A placeholder [`ClientRes`] used when no client feature is enabled. pub struct MockServerFnClientResponse; impl ClientRes for MockServerFnClientResponse { async fn try_into_string(self) -> Result { unimplemented!() } async fn try_into_bytes(self) -> Result { unimplemented!() } #[allow(unreachable_code)] fn try_into_stream( self, ) -> Result> + Send + Sync + 'static, E> { unimplemented!() as Result>, _> } fn status(&self) -> u16 { unimplemented!() } fn status_text(&self) -> String { unimplemented!() } fn location(&self) -> String { unimplemented!() } fn has_redirect(&self) -> bool { unimplemented!() } }