1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-04-18 17:24:03 +03:00
mvfst/quic/codec/ConnectionIdAlgo.h
Hani Damlaj 2660a288b3 Update Company Name
Summary: - as title

Reviewed By: lnicco

Differential Revision: D33513410

fbshipit-source-id: 282b6f512cf83b9abb7990402661135b658f7bd1
2022-01-13 12:07:48 -08:00

58 lines
1.5 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
#pragma once
#include <folly/Expected.h>
#include <quic/QuicException.h>
#include <quic/codec/QuicConnectionId.h>
namespace quic {
/**
* Interface to encode and decode algorithms for ConnectionId given routing
* info (embedded in ServerConnectionIdParams)
*
* NOTE: since several of these methods are called for every single packets,
* and every single connection, it is important to not do any
* blocking call in any of the implementation of these methods.
*/
class ConnectionIdAlgo {
public:
virtual ~ConnectionIdAlgo() = default;
/**
* Check if this implementation of algorithm can parse the given ConnectionId
*/
virtual bool canParse(const ConnectionId& id) const noexcept = 0;
/**
* Parses ServerConnectionIdParams from the given connection id.
*/
virtual folly::Expected<ServerConnectionIdParams, QuicInternalException>
parseConnectionId(const ConnectionId& id) noexcept = 0;
/**
* Encodes the given ServerConnectionIdParams into connection id
*/
virtual folly::Expected<ConnectionId, QuicInternalException>
encodeConnectionId(const ServerConnectionIdParams& params) noexcept = 0;
};
/**
* Factory interface to create ConnectionIdAlgo instance.
*/
class ConnectionIdAlgoFactory {
public:
virtual ~ConnectionIdAlgoFactory() = default;
virtual std::unique_ptr<ConnectionIdAlgo> make() = 0;
};
} // namespace quic