Debian Codegraph @

src/objective-c/GRPCClient/GRPCTransport.h

raw
1 /*
2 *
3 * Copyright 2019 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 // The interface for a transport implementation
20
21 #import "GRPCInterceptor.h"
22
23 NS_ASSUME_NONNULL_BEGIN
24
25 #pragma mark Transport ID
26
27 /**
28 * The default transport implementations available in gRPC. These implementations will be provided
29 * by gRPC by default unless explicitly excluded by the build system.
30 */
31 extern const struct GRPCDefaultTransportImplList {
32 const GRPCTransportID core_secure;
33 const GRPCTransportID core_insecure;
34 } GRPCDefaultTransportImplList;
35
36 /** Returns whether two transport id's are identical. */
37 BOOL TransportIDIsEqual(GRPCTransportID lhs, GRPCTransportID rhs);
38
39 /** Returns the hash value of a transport id. */
40 NSUInteger TransportIDHash(GRPCTransportID);
41
42 #pragma mark Transport and factory
43
44 @protocol GRPCInterceptorInterface;
45 @protocol GRPCResponseHandler;
46 @class GRPCTransportManager;
47 @class GRPCRequestOptions;
48 @class GRPCCallOptions;
49 @class GRPCTransport;
50
51 /** The factory to create a transport. */
52 @protocol GRPCTransportFactory <NSObject>
53
54 /** Create a transport implementation instance. */
55 - (GRPCTransport *)createTransportWithManager:(GRPCTransportManager *)transportManager;
56
57 /** Get a list of factories for transport inteceptors. */
58 @property(nonatomic, readonly) NSArray<id<GRPCInterceptorFactory>> *transportInterceptorFactories;
59
60 @end
61
62 /** The registry of transport implementations. */
63 @interface GRPCTransportRegistry : NSObject
64
65 + (instancetype)sharedInstance;
66
67 /**
68 * Register a transport implementation with the registry. All transport implementations to be used
69 * in a process must register with the registry on process start-up in its +load: class method.
70 * Parameter \p transportID is the identifier of the implementation, and \p factory is the factory
71 * object to create the corresponding transport instance.
72 */
73 - (void)registerTransportWithID:(GRPCTransportID)transportID
74 factory:(id<GRPCTransportFactory>)factory;
75
76 @end
77
78 /**
79 * Base class for transport implementations. All transport implementation should inherit from this
80 * class.
81 */
82 @interface GRPCTransport : NSObject <GRPCInterceptorInterface>
83
84 @end
85
86 NS_ASSUME_NONNULL_END