Vapor Documentation Beta

Structure Byte​Count

public struct ByteCount: Equatable

Represents a number of bytes:

let bytes: ByteCount = "1mb" print(bytes.value) // 1048576

let bytes: ByteCount = 1_000_000 print(bytes.value) // 1000000 let bytes: ByteCount = "2kb" print(bytes.value) // 2048

%3 ByteCount ByteCount ExpressibleByIntegerLiteral ExpressibleByIntegerLiteral ByteCount->ExpressibleByIntegerLiteral Equatable Equatable ByteCount->Equatable ExpressibleByStringLiteral ExpressibleByStringLiteral ByteCount->ExpressibleByStringLiteral

Conforms To

Equatable
ExpressibleByIntegerLiteral
ExpressibleByStringLiteral

Initializers

init(value:​)

public init(value: Int)

init(integer​Literal:​)

public init(integerLiteral value: Int)

Initializes the ByteCount with the raw byte count

Parameters

value Int

The number of bytes

init(string​Literal:​)

public init(stringLiteral value: String)

Initializes the ByteCount via a descriptive string. Available suffixes are: kb, mb, gb, tb

Parameters

value String

The string value (1mb)

Properties

value

let value: Int

The value in Bytes