StorageCrypto Documentation

Protocol Component

public protocol Component  

A protocol defining a unique identifier for a specific request component.

The user can define custom components to be used inside EndpointBuilder.

%81 Component Component Headers Headers Headers->Component Expensive Expensive Expensive->Component Constrained Constrained Constrained->Component Method Method Method->Component Body Body Body->Component Timeout Timeout Timeout->Component Service Service Service->Component Cellular Cellular Cellular->Component Query Query Query->Component

Types Conforming to Component

Cellular

A struct defining whether the request for a given endpoint can run on cellular or not. Defaults to true.

Constrained

A struct defining whether the request for a given endpoint should run on a constrained network. Defaults to true.

Expensive

A struct defining whether the request for a given endpoint is considered expensive. Defaults to true.

Service

A struct defining the request network service type for a specific endpoint. /// Defaults to .default.

Timeout

A struct defining when the request for a given endpoint can timeout. Defaults to 60.

Body

A struct defining the request body for a given endpoint. Defaults to nil.

Headers

A struct defining the request headers for a given endpoint. Defaults to empty.

Method

A struct defining the request HTTP method for a given endpoint.

Query

A struct defining the query items for a given endpoint. Defaults to empty.

Default Implementations

inherit(from:​_:​)

mutating func inherit(from original: any Component)  

Inherit some previously cached value. Default implementation does nothing, meaning cached values are simply overridden.

Path("https://github.com")
PathComponent("sbertix")
PathComponent("ComposableRequest")

would be resolved to the repo path.

Headers("value1", forKey: "key1")
Headers("value2", forKey: "key2")

would be resolved to ["key1": "value1", "key2": "value2"].

Parameters

original any

The original value for the cached component.

Requirements

Value

associatedtype Value

The associated value type.

default​Value

static var defaultValue: Self  

The default value when no cached component can be found.

value

var value: Value  

The value connected to the current component.

inherit(from:​_:​)

mutating func inherit(from original: any Component) 

Inherit some previously cached value. Default implementation simply replaces the current value.

Path("https://github.com")
PathComponent("sbertix")
PathComponent("ComposableRequest")

would be resolved to the repo path.

Headers("value1", forKey: "key1")
Headers("value2", forKey: "key2")

would be resolved to ["key1": "value1", "key2": "value2"].

Parameters

original any

The original value for the cached component.

update(_:​)

func update(_ request: inout URLRequest) 

Update a given URLRequest.

Parameters

request inout URLRequest

A mutable URLRequest.