pub struct ClientSocketBuilder<T: IdentityType + Clone, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler> { /* private fields */ }Expand description
Builder for constructing a ClientSocket.
Implementations§
Source§impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler + 'static> ClientSocketBuilder<T, AE, CC>
impl<T: IdentityType + Clone + 'static, AE: AsyncExecutor + 'static, CC: ClientConnectionHandler + 'static> ClientSocketBuilder<T, AE, CC>
Sourcepub fn new(certificate: ClientCertificate, initial_data_generator: CC) -> Self
pub fn new(certificate: ClientCertificate, initial_data_generator: CC) -> Self
Create a new builder with the given certificate and client connection handler. Decoy providers are randomly selected per-flow by default.
The certificate must contain at least one server address; otherwise build will return
CertificateError::NoAddresses.
By default, a random number of addresses (1 to the total in the certificate) is selected
automatically, each with a random FlowConfig. Call
with_flow_config one or more times to opt out of
auto-selection and configure exactly which flows to open.
Sourcepub fn with_settings(self, settings: Arc<Settings<AE>>) -> Self
pub fn with_settings(self, settings: Arc<Settings<AE>>) -> Self
Set custom settings to use for the socket.
Sourcepub fn with_decoy_factory(self, factory: DecoyFactory<T, AE>) -> Self
pub fn with_decoy_factory(self, factory: DecoyFactory<T, AE>) -> Self
Set the decoy factory used for all flows.
Sourcepub fn with_decoy<DP: DecoyCommunicationMode<T, AE> + 'static>(self) -> Self
pub fn with_decoy<DP: DecoyCommunicationMode<T, AE> + 'static>(self) -> Self
Set a fixed decoy provider type for all flows.
Sourcepub fn with_probe_factory(self, factory: ProbeFactory<AE>) -> Self
pub fn with_probe_factory(self, factory: ProbeFactory<AE>) -> Self
Set the active probe handler factory for all flows.
Sourcepub fn with_probe<PM: ActiveProbeHandler<AE> + Default + 'static>(self) -> Self
pub fn with_probe<PM: ActiveProbeHandler<AE> + Default + 'static>(self) -> Self
Set a fixed active probe handler type for all flows.
Sourcepub fn with_flow_config(self, addr: SocketAddr, config: FlowConfig) -> Self
pub fn with_flow_config(self, addr: SocketAddr, config: FlowConfig) -> Self
Set an explicit FlowConfig for a specific server address.
Calling this method at least once disables auto-flow-selection: only the addresses
configured via this method will be connected. The address must be present in the
certificate; otherwise build will return
ClientSocketError::AddressNotInCertificate.
Sourcepub async fn build(self) -> Result<ClientSocket<T, AE, CC>, ClientSocketError>
pub async fn build(self) -> Result<ClientSocket<T, AE, CC>, ClientSocketError>
Build the client socket, validating all flow configs and creating underlying managers.
Returns ClientSocketError::FlowError wrapping FlowControllerError::AssertionFailed
if the combined flow configuration leaves zero bytes available for user data
(e.g. constant fake-body mode with a per-flow constant length sampled from
[TYPHOON_FAKE_BODY_CONSTANT_LENGTH_MIN, TYPHOON_FAKE_BODY_CONSTANT_LENGTH_MAX] larger than
the remaining packet budget after protocol overhead).