EditionCoverProvider

@MainActor
public protocol EditionCoverProvider

Interface to get the cover for a edition as an image.

The SDK keeps a cache, so it is safe to call these methods in offline mode. If the network fails or can’t be accessed the SDK will use any cached image available, even if it needs to upscale to satisfy boundingBoxSize parameters passed to the methods.

  • This method provides an UIImage with the cover of an edition given a size through boundingBoxSize in points. The cover size is guaranteed to fit in boundingBoxSize. coverSize can be used if you need to calculate an exact size to pass in boundingBoxSize.

    The cover is provided through the the completion callback.

    The method returns a Cancelable that can be used to cancel the operation. If the operation is canceled, completion will be called with canceled.

    Declaration

    Swift

    @MainActor
    func coverImageForEdition(
        edition: Edition,
        boundingBoxSize: CGSize,
        completion: @escaping (_ result: Result<UIImage, Error>) -> Void
    ) -> any Cancelable
  • Create a StartableCancelable for loading the cover image for an edition.

    Declaration

    Swift

    @MainActor
    func startableCoverImageForEdition(
        edition: Edition,
        boundingBoxSize: CGSize
    ) -> StartableResultProvider<UIImage, any Error>

    Parameters

    edition

    The edition whose cover to load.

    boundingBoxSize

    Define the size in which to fit the cover image. You can use coverSize for calculating this value.

    Return Value

    A StartableCancelable that can be used to start the operation and to cancel it. Cancelling the the operation will cause the completion block passed to the start method to be called with canceled.

  • coverImageForEdition(edition:boundingBoxSize:) Extension method, asynchronous

    Asynchronously load the cover image for an edition. The operation supports task cancellation. The error thrown upon cancellation is canceled.

    Declaration

    Swift

    @MainActor
    func coverImageForEdition(
        edition: Edition,
        boundingBoxSize: CGSize
    ) async throws -> UIImage

    Parameters

    edition

    The edition whose cover to load.

    boundingBoxSize

    Define the size in which to fit the cover image. You can use coverSize for calculating this value.