Skip to content
File

Blob: src/rust/kj/ffi.c++

1.1 KB
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5#include "ffi.h"
6 
7#include <workerd/rust/kj/http.rs.h>
8 
9#include <kj/compat/http.h>
10 
11static_assert(sizeof(kj::rust::HttpConnectSettings) == 16, "HttpConnectSettings size mismatch");
12static_assert(alignof(kj::rust::HttpConnectSettings) == alignof(uint64_t),
13 "HttpConnectSettings alignment mismatch");
14 
15namespace kj::rust {
16 
17// This stays out-of-line because HttpConnectSettings is defined in the generated cxx bridge
18// header, and ffi.h cannot include that header without creating an include cycle.
19kj::Promise<void> connect(HttpService& service,
20 ::rust::Slice<const kj::byte> host,
21 const HttpHeaders& headers,
22 AsyncIoStream& connection,
23 ConnectResponse& response,
24 HttpConnectSettings settings) {
25 auto strHost = kj::str(kj::from<kj_rs::Rust>(host).asChars());
26 return service.connect(strHost, headers, connection, response,
27 {
28 .useTls = settings.use_tls,
29 .tlsStarter = settings.tls_starter,
30 });
31}
32 
33} // namespace kj::rust