Types
pyvider.rpcplugin.types
¶
Type definitions for the Pyvider RPC plugin system.
This module provides Protocol classes, TypeVars, and type aliases that define the interfaces and contracts used throughout the pyvider.rpcplugin package. These types enable static type checking and clear API boundaries.
For most users, these types are used only in type annotations. Advanced users implementing custom protocol handlers will need to implement the Protocol interfaces defined here.
Classes¶
ConnectionT
¶
Bases: Protocol
Protocol for transport connections.
This protocol defines the minimal interface for connection objects used by transport implementations.
Functions¶
close
async
¶
receive_data
async
¶
RPCPluginHandler
¶
Bases: Protocol
Protocol defining the interface that all RPC handlers must implement.
This is a runtime-checkable protocol that defines the minimal interface required for a class to serve as a handler for an RPC plugin. The actual methods required will depend on the specific gRPC service being implemented.
RPCPluginProtocol
¶
Bases: Protocol
Protocol defining the interface that all RPC protocol implementations must follow.
This protocol defines the contract for protocol implementations that bridge between gRPC services and Pyvider's RPC plugin system.
Functions¶
add_to_server
async
¶
get_grpc_descriptors
async
¶
get_method_type
¶
Gets the gRPC method type for a given method name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method_name
|
str
|
The full method path (e.g., "/plugin.GRPCStdio/StreamStdio") |
required |
Returns:
| Type | Description |
|---|---|
str
|
String representing the method type (e.g., "unary_unary", "stream_stream") |
Source code in pyvider/rpcplugin/types.py
RPCPluginTransport
¶
Bases: Protocol
Protocol defining the interface that all transport implementations must follow.
This protocol defines the contract for transport implementations that handle the low-level network communication between RPC plugin components.
Functions¶
close
async
¶
connect
async
¶
Connect to a remote endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
The endpoint to connect to |
required |
SecureRpcClientT
¶
Bases: Protocol
Protocol for an RPC client supporting secure transport and handshake.
This protocol defines the interface for clients that support secure communication with mTLS and proper handshake negotiation.
SerializableT
¶
Bases: Protocol
Protocol for objects that can be serialized to/from dict.
This protocol defines the minimal interface for objects that can be serialized to and from dictionary representations.
Functions¶
from_dict
classmethod
¶
Create an object from a dictionary representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing object data |
required |
Returns:
| Type | Description |
|---|---|
SerializableT
|
New instance of the class |
Source code in pyvider/rpcplugin/types.py
Functions¶
is_valid_handler
¶
TypeGuard that checks if an object implements the RPCPluginHandler protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to check |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[RPCPluginHandler]
|
True if the object implements RPCPluginHandler, False otherwise |
Source code in pyvider/rpcplugin/types.py
is_valid_protocol
¶
TypeGuard that checks if an object implements the RPCPluginProtocol protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to check |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[RPCPluginProtocol]
|
True if the object implements RPCPluginProtocol, False otherwise |
Source code in pyvider/rpcplugin/types.py
is_valid_transport
¶
TypeGuard that checks if an object implements the RPCPluginTransport protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to check |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[RPCPluginTransport]
|
True if the object implements RPCPluginTransport, False otherwise |