ObjectIdentifier
internal struct ObjectIdentifier : Hashable
extension ObjectIdentifier: CustomStringConvertible
extension ObjectIdentifier: ExpressibleByStringLiteral
extension ObjectIdentifier: Equatable
The ObjectIdentifier structure represents an Object Identifier (OID) commonly used
in various encoding and security protocols.
An OID is a sequence of integers separated by periods, used to uniquely identify objects in a hierarchical naming structure.
- Tip: The structure provides methods for creating, encoding, and working with OIDs. It also supports basic operations such as concatenation and checking if one OID starts with another.
-
Initializes an
ObjectIdentifierwith an array ofUInt8values.Declaration
Swift
internal init(bytes: [UInt8])Parameters
bytesAn array of
UInt8values representing the OID. -
Initializes an
ObjectIdentifierwith a variadic list ofUInt8values.Declaration
Swift
internal init(bytes: UInt8...)Parameters
bytesA list of
UInt8values representing the OID. -
Initializes an
ObjectIdentifierby extending an existingObjectIdentifierwith additionalUInt8values.Declaration
Swift
internal init(_ initialValue: ObjectIdentifier, bytes: UInt8...)Parameters
initialValueThe initial
ObjectIdentifierto extend.bytesA list of additional
UInt8values to append. -
Initializes an
ObjectIdentifierby decoding an array ofUInt8values representing an ASN.1 encoded OID.Throws
An error if decoding or parsing the OID fails.
Declaration
Swift
internal init(encoded: [UInt8]) throwsParameters
encodedAn array of
UInt8values representing the encoded OID in ASN.1 format. -
Initializes an
ObjectIdentifierbased on an ASN.1 node representing an OID.Throws
An error if the provided
nodeis not a valid ASN.1 OID.Declaration
Swift
internal init(node: ASN1Node) throwsParameters
nodeAn
ASN1Noderepresenting an OID in ASN.1 format. -
Encodes the
ObjectIdentifieras an array ofUInt8values with ASN.1 format.Declaration
Swift
internal func encode() -> [UInt8]Return Value
An array of
UInt8values representing the ASN1 format encoded OID. -
Encodes the
ObjectIdentifieras an array ofUInt8values with a custom tag in ASN.1 format.Declaration
Swift
internal func encode(withTag tag: UInt64) -> [UInt8]Parameters
tagThe custom tag value to use in the encoding.
Return Value
An array of
UInt8values representing the ASN.1 format encoded OID with the specified custom tag. -
Concatenates two
ObjectIdentifierinstances to create a newObjectIdentifier.Declaration
Swift
static func + (rhs: ObjectIdentifier, lhs: ObjectIdentifier) -> ObjectIdentifierParameters
rhsThe right-hand side
ObjectIdentifierto concatenate.lhsThe left-hand side
ObjectIdentifierto concatenate.Return Value
A new
ObjectIdentifiercreated by concatenatingrhsandlhs. -
Checks if the current
ObjectIdentifierstarts with anotherObjectIdentifier, indicating a prefix relationship between them.Declaration
Swift
func starts(with other: ObjectIdentifier) -> BoolParameters
otherThe
ObjectIdentifierto check as a prefix.Return Value
trueif the currentObjectIdentifierstarts withother; otherwise,false. -
Removes the first
lengthelements from the beginning of the data array.This method modifies the underlying data array by removing the specified number of elements from the beginning.
Note
If thelengthparameter is greater than or equal to the size of the data array, the data array will be emptied.Declaration
Swift
mutating func removeFirst(_ length: Int)Parameters
lengthThe number of elements to remove from the beginning of the data array.
-
A human-readable string representation of the
ObjectIdentifier, joining itsUInt8values with periods.Declaration
Swift
var description: String { get } -
Declaration
Swift
typealias StringLiteralType = String -
Declaration
Swift
var rawValue: String { get } -
Initializes an
ObjectIdentifierwith a string literal.This initializer splits the input string into its components, which are then converted to
UInt8values. The resulting array ofUInt8values is used to represent the object identifier.Note
The input string should follow the dot notation for object identifiers.Warning
If the input string cannot be parsed as a valid object identifier, a runtime error will occur.Declaration
Swift
init(stringLiteral value: String)Parameters
valueA string representing the object identifier in dot notation (e.g., “1.2.3”).
-
Compares two
ObjectIdentifierinstances for equality based on their underlyingUInt8data.Declaration
Swift
static func == (rhs: ObjectIdentifier, lhs: ObjectIdentifier) -> BoolParameters
rhsThe right-hand side
ObjectIdentifierto compare.lhsThe left-hand side
ObjectIdentifierto compare.Return Value
trueif theUInt8data ofrhsandlhsis equal; otherwise,false.
View on GitHub
ObjectIdentifier Structure Reference