/*
 * Copyright (c) Apple, Inc.
 * All rights reserved.
 */

_Pragma("once")

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <Tightbeam/tightbeam.h>
#include <Tightbeam/tightbeam_private.h>

__BEGIN_DECLS
_Pragma("clang assume_nonnull begin")
_Pragma("clang diagnostic push")
_Pragma("clang diagnostic ignored \"-Wused-but-marked-unused\"")

/*!
 * @typedef ioservice_ioserviceprotocol
 * @brief Client connection handle for `IOService.IOServiceProtocol`
 * @internal
 * 
 * @discussion
 * This structure represents an outgoing connection handle to
 * a destination endpoint. It should be initalized and then stored.
 * Methods can be invoked on this client using the relevant method
 * functions in this generated source file.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceprotocol {
    tb_client_connection_t connection;
} ioservice_ioserviceprotocol;

/*!
 * @function ioservice_ioserviceprotocol_start
 * @brief Invokes the `IOService.IOServiceProtocol.Start()` service method on the destination
 * @internal
 */
tb_error_t ioservice_ioserviceprotocol_start(const ioservice_ioserviceprotocol *_Nonnull client, bool * result);

/*!
 * @typedef ioservice_ioserviceprotocol_init
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`.
 */
tb_error_t ioservice_ioserviceprotocol_init(ioservice_ioserviceprotocol *_Nonnull client, tb_endpoint_t endpoint);

/*!
 * @typedef ioservice_ioserviceprotocol_init_static
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`
 * and existing references to statically allocated `connection`
 * and `transport`.
 * 
 * The both the `connection` and `transport` pointers must remain
 * valid indefinitely.
 */
tb_error_t ioservice_ioserviceprotocol_init_static(ioservice_ioserviceprotocol *_Nonnull client, tb_endpoint_t endpoint, struct tb_connection_s *_Nonnull connection, struct tb_transport_s *_Nonnull transport);

/*!
 * @function ioservice_ioserviceprotocol__copy
 * @brief Copy a client connection to a new location
 * @internal
 * 
 * @discussion
 * Copies a client connection structure from `src` to `dst`.
 */
void ioservice_ioserviceprotocol__copy(const ioservice_ioserviceprotocol *_Nonnull src, ioservice_ioserviceprotocol *_Nonnull dst);

/*!
 * @function ioservice_ioserviceprotocol__destruct
 * @brief Destruct a client connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further method calls should be invoked
 * on it.
 */
void ioservice_ioserviceprotocol__destruct(ioservice_ioserviceprotocol *_Nonnull client);

/*!
 * @typedef ioservice_ioserviceprotocol__service
 * @brief Service connection handle for `IOService.IOServiceProtocol`
 * @internal
 * 
 * @discussion
 * This structure represents an incoming service handle that
 * is listening on an endpoint. It should be initialized during
 * server start and then stored.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceprotocol__service {
    tb_service_connection_t connection;
} ioservice_ioserviceprotocol__service;

/*!
 * @typedef ioservice_ioserviceprotocol_server
 * @brief Method callback blocks for handling `IOService.IOServiceProtocol` service methods`
 * @internal
 * 
 * @discussion
 * This structure holds callback blocks used to dispatch service
 * methods when received over Tightbeam. Your server-side implementation
 * *should* implement an instance of this structure and pass
 * it as part of configuring your service connection.
 */
typedef struct ioservice_ioserviceprotocol_server {
    /*!
     * @field start
     * @brief Method handler for `IOService.IOServiceProtocol.Start()`
     * @internal
     */
    void (^ start)(bool * result);
} ioservice_ioserviceprotocol_server;

/*!
 * @function ioservice_ioserviceprotocol_server_start
 * @brief Server start method for the `IOService.IOServiceProtocol` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 * 
 * This function leaks the underlying Tightbeam transport and
 * is not recommended for new adoptions.
 */
tb_error_t ioservice_ioserviceprotocol_server_start(tb_endpoint_t ep, const ioservice_ioserviceprotocol_server *_Nonnull server);

/*!
 * @function ioservice_ioserviceprotocol__server_start_owned
 * @brief Server start method for the `IOService.IOServiceProtocol` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 */
tb_error_t ioservice_ioserviceprotocol__server_start_owned(tb_endpoint_t ep, ioservice_ioserviceprotocol__service *_Nonnull service, const ioservice_ioserviceprotocol_server *_Nonnull server);

/*!
 * @function ioservice_ioserviceprotocol__server_stop
 * @brief Destruct a server connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further methods should be invoked
 * on it.
 */
void ioservice_ioserviceprotocol__server_stop(ioservice_ioserviceprotocol__service *_Nonnull service);

/*!
 * @typedef ioservice_ioserviceprivate
 * @brief Client connection handle for `IOService.IOServicePrivate`
 * @internal
 * 
 * @discussion
 * This structure represents an outgoing connection handle to
 * a destination endpoint. It should be initalized and then stored.
 * Methods can be invoked on this client using the relevant method
 * functions in this generated source file.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceprivate {
    tb_client_connection_t connection;
} ioservice_ioserviceprivate;

/*!
 * @function ioservice_ioserviceprivate_startprivate
 * @brief Invokes the `IOService.IOServicePrivate.StartPrivate(id:)` service method on the destination
 * @internal
 */
tb_error_t ioservice_ioserviceprivate_startprivate(const ioservice_ioserviceprivate *_Nonnull client, const uint64_t id, bool * result);

/*!
 * @function ioservice_ioserviceprivate_interruptoccurredprivate
 * @brief Invokes the `IOService.IOServicePrivate.InterruptOccurredPrivate(index:count:)` service method on the destination
 * @internal
 */
tb_error_t ioservice_ioserviceprivate_interruptoccurredprivate(const ioservice_ioserviceprivate *_Nonnull client, const int32_t index, const int32_t count);

/*!
 * @function ioservice_ioserviceprivate_timerfiredprivate
 * @brief Invokes the `IOService.IOServicePrivate.TimerFiredPrivate(timerId:)` service method on the destination
 * @internal
 */
tb_error_t ioservice_ioserviceprivate_timerfiredprivate(const ioservice_ioserviceprivate *_Nonnull client, const uint32_t timerId);

/*!
 * @typedef ioservice_ioserviceprivate_init
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`.
 */
tb_error_t ioservice_ioserviceprivate_init(ioservice_ioserviceprivate *_Nonnull client, tb_endpoint_t endpoint);

/*!
 * @typedef ioservice_ioserviceprivate_init_static
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`
 * and existing references to statically allocated `connection`
 * and `transport`.
 * 
 * The both the `connection` and `transport` pointers must remain
 * valid indefinitely.
 */
tb_error_t ioservice_ioserviceprivate_init_static(ioservice_ioserviceprivate *_Nonnull client, tb_endpoint_t endpoint, struct tb_connection_s *_Nonnull connection, struct tb_transport_s *_Nonnull transport);

/*!
 * @function ioservice_ioserviceprivate__copy
 * @brief Copy a client connection to a new location
 * @internal
 * 
 * @discussion
 * Copies a client connection structure from `src` to `dst`.
 */
void ioservice_ioserviceprivate__copy(const ioservice_ioserviceprivate *_Nonnull src, ioservice_ioserviceprivate *_Nonnull dst);

/*!
 * @function ioservice_ioserviceprivate__destruct
 * @brief Destruct a client connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further method calls should be invoked
 * on it.
 */
void ioservice_ioserviceprivate__destruct(ioservice_ioserviceprivate *_Nonnull client);

/*!
 * @typedef ioservice_ioserviceprivate__service
 * @brief Service connection handle for `IOService.IOServicePrivate`
 * @internal
 * 
 * @discussion
 * This structure represents an incoming service handle that
 * is listening on an endpoint. It should be initialized during
 * server start and then stored.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceprivate__service {
    tb_service_connection_t connection;
} ioservice_ioserviceprivate__service;

/*!
 * @typedef ioservice_ioserviceprivate_server
 * @brief Method callback blocks for handling `IOService.IOServicePrivate` service methods`
 * @internal
 * 
 * @discussion
 * This structure holds callback blocks used to dispatch service
 * methods when received over Tightbeam. Your server-side implementation
 * *should* implement an instance of this structure and pass
 * it as part of configuring your service connection.
 */
typedef struct ioservice_ioserviceprivate_server {
    /*!
     * @field startprivate
     * @brief Method handler for `IOService.IOServicePrivate.StartPrivate(id:)`
     * @internal
     */
    void (^ startprivate)(const uint64_t id, bool * result);
    /*!
     * @field interruptoccurredprivate
     * @brief Method handler for `IOService.IOServicePrivate.InterruptOccurredPrivate(index:count:)`
     * @internal
     */
    void (^ interruptoccurredprivate)(const int32_t index, const int32_t count);
    /*!
     * @field timerfiredprivate
     * @brief Method handler for `IOService.IOServicePrivate.TimerFiredPrivate(timerId:)`
     * @internal
     */
    void (^ timerfiredprivate)(const uint32_t timerId);
} ioservice_ioserviceprivate_server;

/*!
 * @function ioservice_ioserviceprivate_server_start
 * @brief Server start method for the `IOService.IOServicePrivate` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 * 
 * This function leaks the underlying Tightbeam transport and
 * is not recommended for new adoptions.
 */
tb_error_t ioservice_ioserviceprivate_server_start(tb_endpoint_t ep, const ioservice_ioserviceprivate_server *_Nonnull server);

/*!
 * @function ioservice_ioserviceprivate__server_start_owned
 * @brief Server start method for the `IOService.IOServicePrivate` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 */
tb_error_t ioservice_ioserviceprivate__server_start_owned(tb_endpoint_t ep, ioservice_ioserviceprivate__service *_Nonnull service, const ioservice_ioserviceprivate_server *_Nonnull server);

/*!
 * @function ioservice_ioserviceprivate__server_stop
 * @brief Destruct a server connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further methods should be invoked
 * on it.
 */
void ioservice_ioserviceprivate__server_stop(ioservice_ioserviceprivate__service *_Nonnull service);

/*!
 * @typedef ioservice_ioserviceconcrete
 * @brief Client connection handle for `IOService.IOServiceConcrete`
 * @internal
 * 
 * @discussion
 * This structure represents an outgoing connection handle to
 * a destination endpoint. It should be initalized and then stored.
 * Methods can be invoked on this client using the relevant method
 * functions in this generated source file.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceconcrete {
    tb_client_connection_t connection;
} ioservice_ioserviceconcrete;

/*!
 * @function ioservice_ioserviceconcrete_start
 * @brief Invokes the `IOService.IOServiceProtocol.Start()` service method on the destination
 * @internal
 */
tb_error_t ioservice_ioserviceconcrete_start(const ioservice_ioserviceconcrete *_Nonnull client, bool * result);

/*!
 * @typedef ioservice_ioserviceconcrete_init
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`.
 */
tb_error_t ioservice_ioserviceconcrete_init(ioservice_ioserviceconcrete *_Nonnull client, tb_endpoint_t endpoint);

/*!
 * @typedef ioservice_ioserviceconcrete_init_static
 * @brief Client connection initializer
 * @internal
 * 
 * @discussion
 * Initializes a client connection structure using `endpoint`
 * and existing references to statically allocated `connection`
 * and `transport`.
 * 
 * The both the `connection` and `transport` pointers must remain
 * valid indefinitely.
 */
tb_error_t ioservice_ioserviceconcrete_init_static(ioservice_ioserviceconcrete *_Nonnull client, tb_endpoint_t endpoint, struct tb_connection_s *_Nonnull connection, struct tb_transport_s *_Nonnull transport);

/*!
 * @function ioservice_ioserviceconcrete__copy
 * @brief Copy a client connection to a new location
 * @internal
 * 
 * @discussion
 * Copies a client connection structure from `src` to `dst`.
 */
void ioservice_ioserviceconcrete__copy(const ioservice_ioserviceconcrete *_Nonnull src, ioservice_ioserviceconcrete *_Nonnull dst);

/*!
 * @function ioservice_ioserviceconcrete__destruct
 * @brief Destruct a client connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further method calls should be invoked
 * on it.
 */
void ioservice_ioserviceconcrete__destruct(ioservice_ioserviceconcrete *_Nonnull client);

/*!
 * @typedef ioservice_ioserviceconcrete__service
 * @brief Service connection handle for `IOService.IOServiceConcrete`
 * @internal
 * 
 * @discussion
 * This structure represents an incoming service handle that
 * is listening on an endpoint. It should be initialized during
 * server start and then stored.
 *  
 * The internal layout of this structure is an implementation
 * detail and does not represent a stable interface. It may change
 * without warning.
 */
typedef struct ioservice_ioserviceconcrete__service {
    tb_service_connection_t connection;
} ioservice_ioserviceconcrete__service;

/*!
 * @typedef ioservice_ioserviceconcrete_server
 * @brief Method callback blocks for handling `IOService.IOServiceConcrete` service methods`
 * @internal
 * 
 * @discussion
 * This structure holds callback blocks used to dispatch service
 * methods when received over Tightbeam. Your server-side implementation
 * *should* implement an instance of this structure and pass
 * it as part of configuring your service connection.
 */
typedef struct ioservice_ioserviceconcrete_server {
    /*!
     * @field start
     * @brief Method handler for `IOService.IOServiceProtocol.Start()`
     * @internal
     */
    void (^ start)(bool * result);
} ioservice_ioserviceconcrete_server;

/*!
 * @function ioservice_ioserviceconcrete_server_start
 * @brief Server start method for the `IOService.IOServiceConcrete` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 * 
 * This function leaks the underlying Tightbeam transport and
 * is not recommended for new adoptions.
 */
tb_error_t ioservice_ioserviceconcrete_server_start(tb_endpoint_t ep, const ioservice_ioserviceconcrete_server TB_UNUSED *_Nonnull server);

/*!
 * @function ioservice_ioserviceconcrete__server_start_owned
 * @brief Server start method for the `IOService.IOServiceConcrete` service
 * @internal
 * 
 * @discussion
 * This function activates your server handler on the given endpoint
 * `ep`. Once this function returns, your service will be able
 * to begin receiving incoming RPC invocations.
 */
tb_error_t ioservice_ioserviceconcrete__server_start_owned(tb_endpoint_t ep, ioservice_ioserviceconcrete__service *_Nonnull service, const ioservice_ioserviceconcrete_server TB_UNUSED *_Nonnull server);

/*!
 * @function ioservice_ioserviceconcrete__server_stop
 * @brief Destruct a server connection structure
 * @internal
 * 
 * @discussion
 * After a call to this destructor returns, the connection structure
 * is no longer valid and no further methods should be invoked
 * on it.
 */
void ioservice_ioserviceconcrete__server_stop(ioservice_ioserviceconcrete__service *_Nonnull service);
_Pragma("clang diagnostic pop")
_Pragma("clang assume_nonnull end")
__END_DECLS
