Skip to content

Commit 26e3811

Browse files
committed
docs: fix doc comments
1 parent 358d636 commit 26e3811

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/lib.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const EXIT: [u8; 4] = [1, 3, 3, 7];
1818
///
1919
/// # Arguments
2020
///
21-
/// * `response` - Optional static html string send to the user after being redirected. Keep it self-contained and as small as possible. Default: `"<html><body>Please return to the app.</body></html>"`.
2221
/// * `handler` - Closure which will be executed on a successful connection. It receives the full URL as a String.
2322
///
2423
/// # Errors
@@ -32,12 +31,37 @@ pub fn start<F: FnMut(String) + Send + 'static>(handler: F) -> Result<u16, std::
3231
start_with_config(OauthConfig::default(), handler)
3332
}
3433

34+
/// The optional server config.
3535
#[derive(Default, serde::Deserialize)]
3636
pub struct OauthConfig {
37+
/// An array of hard-coded ports the server should try to bind to.
38+
/// This should only be used if your oauth provider does not accept wildcard localhost addresses.
39+
///
40+
/// Default: Asks the system for a free port.
3741
pub ports: Option<Vec<u16>>,
42+
/// Optional static html string send to the user after being redirected.
43+
/// Keep it self-contained and as small as possible.
44+
///
45+
/// Default: `"<html><body>Please return to the app.</body></html>"`.
3846
pub response: Option<Cow<'static, str>>,
3947
}
4048

49+
/// Starts the localhost (using 127.0.0.1) server. Returns the port its listening on.
50+
///
51+
/// Because of the unprotected localhost port, you _must_ verify the URL in the handler function.
52+
///
53+
/// # Arguments
54+
///
55+
/// * `config` - Configuration the server should use, see [`OauthConfig.]
56+
/// * `handler` - Closure which will be executed on a successful connection. It receives the full URL as a String.
57+
///
58+
/// # Errors
59+
///
60+
/// - Returns `std::io::Error` if the server creation fails.
61+
///
62+
/// # Panics
63+
///
64+
/// The seperate server thread can panic if its unable to send the html response to the client. This may change after more real world testing.
4165
pub fn start_with_config<F: FnMut(String) + Send + 'static>(
4266
config: OauthConfig,
4367
mut handler: F,
@@ -208,7 +232,11 @@ mod plugin_impl {
208232
}
209233
}
210234

211-
/// Initializes the plugin.
235+
/// Initializes the tauri plugin.
236+
/// Only use this if you need the JavaScript APIs.
237+
///
238+
/// Note for the `start()` command: If `response` is not provided it will fall back to the config
239+
/// in tauri.conf.json if set and will fall back to the library's default, see [`OauthConfig`].
212240
#[must_use]
213241
pub fn init<R: Runtime>() -> TauriPlugin<R> {
214242
Builder::new("oauth")

0 commit comments

Comments
 (0)