settings
import std::net::http2::settings; · source
HTTP/2 SETTINGS parameters, RFC 7540 section 6.5. A SETTINGS frame payload is a sequence of 6-octet entries: a 16-bit identifier followed by a 32-bit value.
Types
Settings
type struct Settings {
header_table_size: u32;
enable_push: u32;
max_concurrent_streams: u32;
initial_window_size: u32;
max_frame_size: u32;
max_header_list_size: u32;
}
The six parameters of one side of a connection, one field per identifier. The type is internal to the library: Http2Connection keeps one for each side and applies what the peer sends, and this section says what that does. It starts from defaults() — the protocol defaults, with the u32 maximum standing for "unlimited" — and fold a received payload in with apply_payload; unknown identifiers are ignored, as the protocol requires.
A value the protocol forbids is refused with the error code the connection must end with, and stores nothing: PROTOCOL_ERROR for SETTINGS_ENABLE_PUSH other than 0 or 1 and for SETTINGS_MAX_FRAME_SIZE outside MIN_MAX_FRAME_SIZE to MAX_MAX_FRAME_SIZE, and FLOW_CONTROL_ERROR for SETTINGS_INITIAL_WINDOW_SIZE above MAX_WINDOW_SIZE. apply_payload refuses a length that is not a multiple of 6 with FRAME_SIZE_ERROR; at the first value it refuses, the entries before it stay applied.
Properties
| Property | Type |
|---|---|
header_table_size | u32 |
enable_push | u32 |
max_concurrent_streams | u32 |
initial_window_size | u32 |
max_frame_size | u32 |
max_header_list_size | u32 |
Constructors
static defaults() -> Settings;
static defaults() -> Settings;Protocol defaults (RFC 7540 section 6.5.2). "Unlimited" parameters use the u32 maximum as a sentinel.
Methods
apply_one(mut &this, id: u16, value: u32) -> Result<(), u32>;
apply_one(mut &this, id: u16, value: u32) -> Result<(), u32>;Apply a single parsed (identifier, value). Unknown identifiers are ignored. A value the protocol forbids is refused with the error code the connection must end with, and stores nothing: PROTOCOL_ERROR for SETTINGS_ENABLE_PUSH other than 0 or 1 and for SETTINGS_MAX_FRAME_SIZE outside 16384 to 16777215, and FLOW_CONTROL_ERROR for SETTINGS_INITIAL_WINDOW_SIZE above 2^31 - 1.
apply_payload(mut &this, payload: &Slice<u8>) -> Result<(), u32>;
apply_payload(mut &this, payload: &Slice<u8>) -> Result<(), u32>;Parse a SETTINGS frame payload, applying its entries in order. Refused with FRAME_SIZE_ERROR when the length is not a multiple of 6, and with apply_one's code at the first value it refuses; the entries before that one stay applied.
Free Functions
function push_entry(out: mut &Array<u8>, id: u16, value: u32) -> void;
function push_entry(out: mut &Array<u8>, id: u16, value: u32) -> void;Append a (identifier, value) entry to a SETTINGS payload buffer.
A payload to send is built one entry at a time, then queued as a FRAME_SETTINGS frame.
Constants
const SETTINGS_HEADER_TABLE_SIZE: u16 = 0x1;
const SETTINGS_ENABLE_PUSH: u16 = 0x2;
const SETTINGS_MAX_CONCURRENT_STREAMS: u16 = 0x3;
const SETTINGS_INITIAL_WINDOW_SIZE: u16 = 0x4;
const SETTINGS_MAX_FRAME_SIZE: u16 = 0x5;
const SETTINGS_MAX_HEADER_LIST_SIZE: u16 = 0x6;
const MAX_WINDOW_SIZE: u32 = 2147483647;
const MIN_MAX_FRAME_SIZE: u32 = 16384;
const MAX_MAX_FRAME_SIZE: u32 = 16777215;type struct Name { ... }
type enum Name { ... }
type trait Name { ... }
type union Name { ... }Begins a type declaration; the keyword that follows says which kind. On its own, type Name = Existing; declares an alias.
type struct Name {
field: Type;
method(&this) -> Ret { ... }
}A value type with named fields and optional methods. Structs live on the stack and are passed by value. Fields are public by default and may carry = default values; methods take their receiver as &this, mut &this, or this.
type struct SettingsSettings.header_table_size: u32Settings.enable_push: u32Settings.max_concurrent_streams: u32Settings.initial_window_size: u32Settings.max_frame_size: u32Settings.max_header_list_size: u32const NAME: Type = value;At module level, a true compile-time constant, conventionally SCREAMING_SNAKE_CASE. (mut at module level declares mutable global state instead.)
const SETTINGS_HEADER_TABLE_SIZE: u16 = 0x1;const SETTINGS_ENABLE_PUSH: u16 = 0x2;const SETTINGS_MAX_CONCURRENT_STREAMS: u16 = 0x3;const SETTINGS_INITIAL_WINDOW_SIZE: u16 = 0x4;const SETTINGS_MAX_FRAME_SIZE: u16 = 0x5;const SETTINGS_MAX_HEADER_LIST_SIZE: u16 = 0x6;const MAX_WINDOW_SIZE: u32 = 2147483647;const MIN_MAX_FRAME_SIZE: u32 = 16384;const MAX_MAX_FRAME_SIZE: u32 = 16777215;import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
namespace std::net::http2;net::http2: HTTP/2 (RFC 7540) with HPACK header compression (RFC 7541).
module pageconst SETTINGS_ENABLE_PUSH: u16 = 0x2;const SETTINGS_MAX_FRAME_SIZE: u16 = 0x5;const MIN_MAX_FRAME_SIZE: u32 = 16384;const MAX_MAX_FRAME_SIZE: u32 = 16777215;const SETTINGS_INITIAL_WINDOW_SIZE: u16 = 0x4;const MAX_WINDOW_SIZE: u32 = 2147483647;static name(param: Type) -> Ret { ... }A method that belongs to the type rather than an instance, called as Type::name(..). For structs, static new(..) returning a struct literal is the idiomatic constructor.
type struct Settingsmut &this
mut &TypeAn exclusive, mutating borrow. As a receiver, mut &this lets the method modify the fields - and callers can see that from the signature alone. As a parameter type, mut &T lets the callee mutate through the reference while the caller keeps ownership.
&this
mut &this
thisThe receiver of a method. Its first parameter declares how the method takes it: &this borrows read-only, mut &this borrows exclusively, and this / mut this move the value in and consume it. In the body, this.field reaches the members.
(parameter) id: u16(parameter) value: u32type enum Result<T, E> with [Eq, Clone, Debug] {
Ok(T);
Err(E);
}The outcome of an operation that can fail: Ok(value) on success, Err(error) on failure.
primitive ()The unit type: a value that carries no information, and the empty tuple. Distinct from void, which is the absence of a value - Result<(), E> succeeds with nothing to return. 0 bytes.
(parameter) payload: &Slice<u8>type struct Slice<T> {}The elements are reached through ptr, declared read-only: through a mut &Slice<T> it reads as a writable pointer, through a &Slice<T> as the read-only one it is.
function name<T>(param: Type) -> Ret { ... }Declares a function. Parameters are written name: Type and are never inferred; the return type follows -> and defaults to void. Declaration order does not matter: every signature is collected before any body is checked, so functions may call each other freely and recurse.
function push_entry(out: mut &Array<u8>, id: u16, value: u32) -> voidAppend a (identifier, value) entry to a SETTINGS payload buffer.
(parameter) out: mut &Array<u8>type struct Array<T, A = GlobalAllocator> where A: Allocator {}A growable sequence of Ts stored contiguously, owning its elements; A is the allocator its storage comes from. Indexing out of range panics; get answers None instead.