Skip to content
Merged
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
28 changes: 9 additions & 19 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ where
/// # Examples
///
/// ```no_run
/// # use wireframe::server::WireframeServer;
/// # let factory = || WireframeApp::new().unwrap();
/// # struct MyPreamble;
/// let server = WireframeServer::new(factory).with_preamble::<MyPreamble>();
/// use wireframe::{app::WireframeApp, server::WireframeServer};
/// #[derive(bincode::Decode)]
/// struct MyPreamble;
/// let server = WireframeServer::new(|| WireframeApp::default())
/// .with_preamble::<MyPreamble>();
/// ```
#[must_use]
pub fn with_preamble<P>(self) -> WireframeServer<F, P>
Expand All @@ -122,7 +123,8 @@ where
{
/// Set the number of worker tasks to spawn for the server.
///
/// Ensures at least one worker is configured.
/// The count is clamped to at least one so a worker is always
/// present. Returns a new server instance with the updated value.
///
/// # Examples
///
Expand All @@ -131,23 +133,11 @@ where
///
/// let factory = || WireframeApp::new().unwrap();
/// let server = WireframeServer::new(factory).workers(4);
/// ```
#[must_use]
/// Sets the number of worker tasks to spawn, ensuring at least one worker is configured.
///
/// Returns a new `WireframeServer` instance with the updated worker count. If `count` is less than 1, it defaults to 1.
///
/// # Examples
///
/// ```ignore
/// use wireframe::{app::WireframeApp, server::WireframeServer};
///
/// let factory = || WireframeApp::new().unwrap();
/// let server = WireframeServer::new(factory).workers(4);
/// assert_eq!(server.worker_count(), 4);
/// let server = server.workers(0);
/// assert_eq!(server.worker_count(), 1);
/// ```
#[must_use]
pub fn workers(mut self, count: usize) -> Self {
self.workers = count.max(1);
self
Expand Down Expand Up @@ -181,7 +171,7 @@ where
///
/// # Examples
///
/// ```ignore
/// ```no_run
/// use wireframe::{app::WireframeApp, server::WireframeServer};
///
/// let factory = || WireframeApp::new().unwrap();
Expand Down
Loading