Skip to content

Commit

Permalink
Merge pull request #14 from LemmyNet/domain
Browse files Browse the repository at this point in the history
Expose ClientOptions
  • Loading branch information
SleeplessOne1917 authored Jun 16, 2024
2 parents 9b7b4ae + e845617 commit 5b59dda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/lemmy_client_internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cfg_if! {
if #[cfg(target_family = "wasm")] {
use gloo_net::http::{Request, RequestBuilder};
use web_sys::wasm_bindgen::UnwrapThrowExt;
pub struct Fetch(ClientOptions);
pub struct Fetch(pub ClientOptions);

impl Fetch {
pub fn new(options: ClientOptions) -> Self {
Expand Down Expand Up @@ -144,7 +144,7 @@ cfg_if! {

pub struct ClientWrapper {
client: reqwest::Client,
options: ClientOptions
pub options: ClientOptions
}

impl ClientWrapper {
Expand Down
20 changes: 17 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
//!
//! assert!(res.is_ok());
//! }
//!
//! ## IMPORTANT NOTICE
//! This crate now uses a different versioning scheme than before so as not to be too tied down to Lemmy releases. For Lemmy versions 0.19.4 and up, use versions 1.x.x. For Lemmy versions 0.19.3 and under, use versions 0.19.5 and up. This is confusing, but should become a non issue as Lemmy accumulates versions and fewer servers use Lemmy versions use 0.19.3 and lower.
//!
//! ```
//! //! ## IMPORTANT NOTICE
//! This crate now uses a different versioning scheme than before so as not to be too tied down to Lemmy releases. For Lemmy versions 0.19.4 and up, use versions 1.x.x. For Lemmy versions 0.19.3 and under, use versions 0.19.5 and up. This is confusing, but should become a non issue as Lemmy accumulates versions and fewer servers use Lemmy versions use 0.19.3 and lower.
use std::collections::HashMap;

use crate::{lemmy_client_trait::LemmyClientInternal, response::LemmyResult};
Expand Down Expand Up @@ -57,6 +58,19 @@ pub struct LemmyClient {
client: ClientWrapper,
}

impl LemmyClient {
/// Get the options the client is using.
pub fn options(&self) -> &ClientOptions {
cfg_if! {
if #[cfg(target_family = "wasm")] {
&self.client.0
} else {
&self.client.options
}
}
}
}

macro_rules! expose_wrapped_fn {
($name:ident, $form:ty, $response:ty, $doc:expr) => {
#[doc = $doc]
Expand Down

0 comments on commit 5b59dda

Please sign in to comment.