chromium/components/qr_code_generator/qr_code_generator.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_QR_CODE_GENERATOR_QR_CODE_GENERATOR_H_
#define COMPONENTS_QR_CODE_GENERATOR_QR_CODE_GENERATOR_H_

#include <stddef.h>
#include <stdint.h>

#include <optional>
#include <vector>

#include "base/containers/span.h"
#include "base/types/expected.h"
#include "components/qr_code_generator/error.h"

namespace qr_code_generator {

// Contains output data from Generate().
// The default state contains no data.
struct GeneratedCode {};

// Generates a QR code containing the given data.
// The generator will attempt to choose a version that fits the data and which
// is >= |min_version|, if given. The returned span's length is
// input-dependent and not known at compile-time.
base::expected<GeneratedCode, Error> GenerateCode(
    base::span<const uint8_t> in,
    std::optional<int> min_version = std::nullopt);

}  // namespace qr_code_generator

#endif  // COMPONENTS_QR_CODE_GENERATOR_QR_CODE_GENERATOR_H_