Files
transmission/libtransmission/api-compat.h
Charles Kerr 9a792046f3 feat: add libtransmission::api_compat::convert() (#7917)
Add a module to convert between tr4 and tr5 RPC / settings / config file payloads.

This will be used as a compatibility layer between Transmission 5's naming scheme
and Transmission <= 4.

Co-authored-by: Yat Ho <lagoho7@gmail.com>
Co-authored-by: Dzmitry Neviadomski <nevack.d@gmail.com>
2025-12-14 10:56:07 -06:00

37 lines
992 B
C++

// This file Copyright © Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#pragma once
#include <cstdint> // uint8_t
#include "libtransmission/quark.h"
struct tr_variant;
namespace libtransmission::api_compat
{
enum class Style : uint8_t
{
Tr4, // bespoke RPC, mixed-case keys,
Tr5, // jsonrpc, all snake_case keys
};
[[nodiscard]] tr_variant convert(tr_variant const& src, Style tgt_style);
[[nodiscard]] Style get_export_settings_style();
[[nodiscard]] tr_variant convert_incoming_data(tr_variant const& src);
[[nodiscard]] tr_variant convert_outgoing_data(tr_variant const& src);
} // namespace libtransmission::api_compat
/**
* Get the replacement quark from old deprecated quarks.
*
* Note: Temporary shim just for the transition period to snake_case.
*/
[[nodiscard]] tr_quark tr_quark_convert(tr_quark quark);