ByteIndex

public struct ByteIndex { /* private fields */ }

A typed wrapper for a byte position within a String.

ByteIndex exists so that APIs taking string positions can refuse raw Int64s, which removes the "is this a byte offset or a char offset?" ambiguity at the call site. The wrapped value is a plain UTF-8 byte offset; arithmetic is the caller's responsibility.

Representation

A single Int64 field.

Properties

public var value: Int64

The wrapped byte offset.

Initializers

public init(Int64)

Wraps a raw byte offset.

Methods

public func advance(by: Int64) -> ByteIndex

Advances by n bytes. Pure arithmetic — no string needed.

ImplementsEquatable

Associated Types

type Output = Bool

Methods

public func equal(to: Self) -> Bool

Bridges Equal.equal(to:) to Equatable.isEqual(to:).

public func isEqual(to: ByteIndex) -> Bool

Returns true if the two indices wrap the same byte offset.

public func notEqual(to: Self) -> Bool

Default !=: delegates to == so there's a single source of truth.

ImplementsComparable

Associated Types

type Output = Bool

Methods

public func compare(ByteIndex) -> Ordering

Compares two byte indices by their wrapped offsets.

public func greaterThan(Self) -> Bool

> derived from compare.

public func greaterThanOrEqual(Self) -> Bool

>= derived from compare.

public func isAtLeast(Self) -> Bool

start.. lower-bound check, derived from compare.

public func isAtMost(Self) -> Bool

..=end upper-bound check, derived from compare.

public func isBelow(Self) -> Bool

..<end upper-bound check, derived from compare.

public func lessThan(Self) -> Bool

< derived from compare.

public func lessThanOrEqual(Self) -> Bool

<= derived from compare.

ImplementsBytesIndex

Associated Types

type BytesYield = UInt8

Methods

public func readBytes(from: BytesView) -> UInt8
public func readBytesChecked(from: BytesView) -> UInt8?
public func readBytesUnchecked(from: BytesView) -> UInt8

Defined in lang/std/text/views.ks