sapling/eden/mononoke/scs_server/metadata.cpp
David Tolnay f9ae9f62c1 Use safe cxx signature for metadata creation
Summary:
This diff cleans up all remaining places that Thrift metadata is being created as a raw pointer, which had to be converted unsafely to UniquePtr in D30180770 (ff5931b944).

It also eliminates all the places that definitions of `MetadataFunc` and `RustThriftMetadata` were duplicated across the codebase. It would have been UB if any of these were to fall out of sync, as I discovered when trying to adjust the representation of RustThriftMetadata in D30180770 (ff5931b944).

Reviewed By: guswynn

Differential Revision: D30182979

fbshipit-source-id: 3313440313f28863ac378986c04522d358cb4fd5
2021-08-11 05:23:27 -07:00

28 lines
879 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "eden/mononoke/scs_server/metadata.h"
#include "eden/mononoke/scs/if/gen-cpp2/source_control_metadata.h" // @manual=//eden/mononoke/scs/if:source_control-cpp2
namespace facebook {
namespace scm {
namespace service {
std::unique_ptr<rust::srserver::RustThriftMetadata> create_metadata() noexcept {
auto meta = std::make_unique<rust::srserver::RustThriftMetadata>();
meta->meta_ =
[](apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
::apache::thrift::detail::md::ServiceMetadata<
::facebook::scm::service::SourceControlServiceSvIf>::gen(response);
};
return meta;
}
} // namespace service
} // namespace scm
} // namespace facebook