KeyPathStorage

extension MoEngageStorage.KeyPathStorage: MoEngageStorage.ReadOnlyLocation
extension MoEngageStorage.KeyPathStorage: @unchecked Sendable
extension MoEngageStorage.KeyPathStorage: MoEngageStorage.WriteOnlyLocation
where
    Location: MoEngageStorage.WriteOnlyLocation,
    Path: WritableKeyPath<Location.Stored, Value>,
    Location.Input == Void,
    Location.Stored == Location.Saved
extension MoEngageStorage.KeyPathStorage: MoEngageStorage.MigratableLocation
where
    Self: MoEngageStorage.WriteOnlyLocation,
    Value: MoEngageStorage.ResettableValue
extension MoEngageStorage.KeyPathStorage: Equatable where Location: Equatable
extension MoEngageStorage.KeyPathStorage: Hashable where Location: Hashable
  • Reads the sub-value at keyPath from the underlying location.

    Declaration

    Swift

    public func read(
        withInput input: Location.Input,
        fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(Location.ReadError) -> Value

    Parameters

    input

    Forwarded to the underlying location’s read.

    sdkInstance

    The isolated SDK instance to read from.

    Return Value

    The value at the key path within the stored composite value.

Available where Location: MoEngageStorage.WriteOnlyLocation, Path: WritableKeyPath<Location.Stored, Value>, Location.Input == Void, Location.Stored == Location.Saved

  • Writes a value at keyPath by loading the current Root, mutating the field, and saving the modified Root back.

    If reading the current root throws, the error is wrapped in WriteOperationError/readFailed(_:). If the subsequent write throws, the error is wrapped in WriteOperationError/writeFailed(_:).

    Declaration

    Swift

    public func write(
        _ value: Value,
        toInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(WriteOperationError<Location.ReadError, Location.WriteError>) -> Location.Output

    Parameters

    value

    The new sub-value to store.

    sdkInstance

    The isolated SDK instance to write to.

Available where Self: MoEngageStorage.WriteOnlyLocation, Value: MoEngageStorage.ResettableValue

  • Resets the field at keyPath to MoEngageStorage/ResettableValue/resetValue.

    Delegates to write, so the error type mirrors WriteOperationError: WriteOperationError/readFailed(_:) if loading the root fails, or WriteOperationError/writeFailed(_:) if saving fails.

    Declaration

    Swift

    public func remove(
        fromInstance sdkInstance: isolated MoEngageSDKInstance = #isolation
    ) throws(WriteOperationError<Location.ReadError, Location.WriteError>) -> Location.Output

    Parameters

    sdkInstance

    The isolated SDK instance to write to.