Skip to content

Commit dac07ea

Browse files
Merge pull request #361 from alexheretic/docs++
Clarify `WebSocketConfig` docs
2 parents 57d9e23 + 2345e28 commit dac07ea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/protocol/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,21 @@ pub struct WebSocketConfig {
4242
/// to the underlying stream.
4343
/// The default value is 128 KiB.
4444
///
45+
/// If set to `0` each message will be eagerly written to the underlying stream.
46+
/// It is often more optimal to allow them to buffer a little, hence the default value.
47+
///
4548
/// Note: [`flush`](WebSocket::flush) will always fully write the buffer regardless.
4649
pub write_buffer_size: usize,
4750
/// The max size of the write buffer in bytes. Setting this can provide backpressure
4851
/// in the case the write buffer is filling up due to write errors.
4952
/// The default value is unlimited.
5053
///
51-
/// Note: Should always be set higher than [`write_buffer_size`](Self::write_buffer_size).
54+
/// Note: The write buffer only builds up past [`write_buffer_size`](Self::write_buffer_size)
55+
/// when writes to the underlying stream are failing. So the **write buffer can not
56+
/// fill up if you are not observing write errors even if not flushing**.
57+
///
58+
/// Note: Should always be at least [`write_buffer_size + 1 message`](Self::write_buffer_size)
59+
/// and probably a little more depending on error handling strategy.
5260
pub max_write_buffer_size: usize,
5361
/// The maximum size of a message. `None` means no size limit. The default value is 64 MiB
5462
/// which should be reasonably big for all normal use-cases but small enough to prevent

0 commit comments

Comments
 (0)