annotate win32-mingw/include/capnp/serialize-async.h @ 50:37d53a7e8262

Headers for KJ/Capnp Win32
author Chris Cannam
date Wed, 26 Oct 2016 13:18:45 +0100
parents
children eccd51b72864
rev   line source
Chris@50 1 // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
Chris@50 2 // Licensed under the MIT License:
Chris@50 3 //
Chris@50 4 // Permission is hereby granted, free of charge, to any person obtaining a copy
Chris@50 5 // of this software and associated documentation files (the "Software"), to deal
Chris@50 6 // in the Software without restriction, including without limitation the rights
Chris@50 7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Chris@50 8 // copies of the Software, and to permit persons to whom the Software is
Chris@50 9 // furnished to do so, subject to the following conditions:
Chris@50 10 //
Chris@50 11 // The above copyright notice and this permission notice shall be included in
Chris@50 12 // all copies or substantial portions of the Software.
Chris@50 13 //
Chris@50 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Chris@50 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Chris@50 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Chris@50 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Chris@50 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Chris@50 19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Chris@50 20 // THE SOFTWARE.
Chris@50 21
Chris@50 22 #ifndef CAPNP_SERIALIZE_ASYNC_H_
Chris@50 23 #define CAPNP_SERIALIZE_ASYNC_H_
Chris@50 24
Chris@50 25 #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS)
Chris@50 26 #pragma GCC system_header
Chris@50 27 #endif
Chris@50 28
Chris@50 29 #include <kj/async-io.h>
Chris@50 30 #include "message.h"
Chris@50 31
Chris@50 32 namespace capnp {
Chris@50 33
Chris@50 34 kj::Promise<kj::Own<MessageReader>> readMessage(
Chris@50 35 kj::AsyncInputStream& input, ReaderOptions options = ReaderOptions(),
Chris@50 36 kj::ArrayPtr<word> scratchSpace = nullptr);
Chris@50 37 // Read a message asynchronously.
Chris@50 38 //
Chris@50 39 // `input` must remain valid until the returned promise resolves (or is canceled).
Chris@50 40 //
Chris@50 41 // `scratchSpace`, if provided, must remain valid until the returned MessageReader is destroyed.
Chris@50 42
Chris@50 43 kj::Promise<kj::Maybe<kj::Own<MessageReader>>> tryReadMessage(
Chris@50 44 kj::AsyncInputStream& input, ReaderOptions options = ReaderOptions(),
Chris@50 45 kj::ArrayPtr<word> scratchSpace = nullptr);
Chris@50 46 // Like `readMessage` but returns null on EOF.
Chris@50 47
Chris@50 48 kj::Promise<void> writeMessage(kj::AsyncOutputStream& output,
Chris@50 49 kj::ArrayPtr<const kj::ArrayPtr<const word>> segments)
Chris@50 50 KJ_WARN_UNUSED_RESULT;
Chris@50 51 kj::Promise<void> writeMessage(kj::AsyncOutputStream& output, MessageBuilder& builder)
Chris@50 52 KJ_WARN_UNUSED_RESULT;
Chris@50 53 // Write asynchronously. The parameters must remain valid until the returned promise resolves.
Chris@50 54
Chris@50 55 // =======================================================================================
Chris@50 56 // inline implementation details
Chris@50 57
Chris@50 58 inline kj::Promise<void> writeMessage(kj::AsyncOutputStream& output, MessageBuilder& builder) {
Chris@50 59 return writeMessage(output, builder.getSegmentsForOutput());
Chris@50 60 }
Chris@50 61
Chris@50 62 } // namespace capnp
Chris@50 63
Chris@50 64 #endif // CAPNP_SERIALIZE_ASYNC_H_