Files
stable-diffusion-rpc/Sources/StableDiffusionProtos/host.grpc.swift
2024-11-03 03:51:25 -05:00

316 lines
10 KiB
Swift

//
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the protocol buffer compiler.
// Source: host.proto
//
import GRPC
import NIO
import NIOConcurrencyHelpers
import SwiftProtobuf
///*
/// The model service, for management and loading of models.
///
/// Usage: instantiate `SdHostModelServiceClient`, then call methods of this protocol to make API calls.
public protocol SdHostModelServiceClientProtocol: GRPCClient {
var serviceName: String { get }
var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? { get }
func loadModel(
_ request: SdLoadModelRequest,
callOptions: CallOptions?
) -> UnaryCall<SdLoadModelRequest, SdLoadModelResponse>
}
extension SdHostModelServiceClientProtocol {
public var serviceName: String {
return "gay.pizza.stable.diffusion.HostModelService"
}
///*
/// Loads a model onto a compute unit.
///
/// - Parameters:
/// - request: Request to send to LoadModel.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
public func loadModel(
_ request: SdLoadModelRequest,
callOptions: CallOptions? = nil
) -> UnaryCall<SdLoadModelRequest, SdLoadModelResponse> {
return self.makeUnaryCall(
path: SdHostModelServiceClientMetadata.Methods.loadModel.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
)
}
}
@available(*, deprecated)
extension SdHostModelServiceClient: @unchecked Sendable {}
@available(*, deprecated, renamed: "SdHostModelServiceNIOClient")
public final class SdHostModelServiceClient: SdHostModelServiceClientProtocol {
private let lock = Lock()
private var _defaultCallOptions: CallOptions
private var _interceptors: SdHostModelServiceClientInterceptorFactoryProtocol?
public let channel: GRPCChannel
public var defaultCallOptions: CallOptions {
get { self.lock.withLock { return self._defaultCallOptions } }
set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
}
public var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? {
get { self.lock.withLock { return self._interceptors } }
set { self.lock.withLockVoid { self._interceptors = newValue } }
}
/// Creates a client for the gay.pizza.stable.diffusion.HostModelService service.
///
/// - Parameters:
/// - channel: `GRPCChannel` to the service host.
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
/// - interceptors: A factory providing interceptors for each RPC.
public init(
channel: GRPCChannel,
defaultCallOptions: CallOptions = CallOptions(),
interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self._defaultCallOptions = defaultCallOptions
self._interceptors = interceptors
}
}
public struct SdHostModelServiceNIOClient: SdHostModelServiceClientProtocol {
public var channel: GRPCChannel
public var defaultCallOptions: CallOptions
public var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol?
/// Creates a client for the gay.pizza.stable.diffusion.HostModelService service.
///
/// - Parameters:
/// - channel: `GRPCChannel` to the service host.
/// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
/// - interceptors: A factory providing interceptors for each RPC.
public init(
channel: GRPCChannel,
defaultCallOptions: CallOptions = CallOptions(),
interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self.defaultCallOptions = defaultCallOptions
self.interceptors = interceptors
}
}
///*
/// The model service, for management and loading of models.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public protocol SdHostModelServiceAsyncClientProtocol: GRPCClient {
static var serviceDescriptor: GRPCServiceDescriptor { get }
var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? { get }
func makeLoadModelCall(
_ request: SdLoadModelRequest,
callOptions: CallOptions?
) -> GRPCAsyncUnaryCall<SdLoadModelRequest, SdLoadModelResponse>
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdHostModelServiceAsyncClientProtocol {
public static var serviceDescriptor: GRPCServiceDescriptor {
return SdHostModelServiceClientMetadata.serviceDescriptor
}
public var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? {
return nil
}
public func makeLoadModelCall(
_ request: SdLoadModelRequest,
callOptions: CallOptions? = nil
) -> GRPCAsyncUnaryCall<SdLoadModelRequest, SdLoadModelResponse> {
return self.makeAsyncUnaryCall(
path: SdHostModelServiceClientMetadata.Methods.loadModel.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdHostModelServiceAsyncClientProtocol {
public func loadModel(
_ request: SdLoadModelRequest,
callOptions: CallOptions? = nil
) async throws -> SdLoadModelResponse {
return try await self.performAsyncUnaryCall(
path: SdHostModelServiceClientMetadata.Methods.loadModel.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? []
)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct SdHostModelServiceAsyncClient: SdHostModelServiceAsyncClientProtocol {
public var channel: GRPCChannel
public var defaultCallOptions: CallOptions
public var interceptors: SdHostModelServiceClientInterceptorFactoryProtocol?
public init(
channel: GRPCChannel,
defaultCallOptions: CallOptions = CallOptions(),
interceptors: SdHostModelServiceClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self.defaultCallOptions = defaultCallOptions
self.interceptors = interceptors
}
}
public protocol SdHostModelServiceClientInterceptorFactoryProtocol: Sendable {
/// - Returns: Interceptors to use when invoking 'loadModel'.
func makeLoadModelInterceptors() -> [ClientInterceptor<SdLoadModelRequest, SdLoadModelResponse>]
}
public enum SdHostModelServiceClientMetadata {
public static let serviceDescriptor = GRPCServiceDescriptor(
name: "HostModelService",
fullName: "gay.pizza.stable.diffusion.HostModelService",
methods: [
SdHostModelServiceClientMetadata.Methods.loadModel,
]
)
public enum Methods {
public static let loadModel = GRPCMethodDescriptor(
name: "LoadModel",
path: "/gay.pizza.stable.diffusion.HostModelService/LoadModel",
type: GRPCCallType.unary
)
}
}
///*
/// The model service, for management and loading of models.
///
/// To build a server, implement a class that conforms to this protocol.
public protocol SdHostModelServiceProvider: CallHandlerProvider {
var interceptors: SdHostModelServiceServerInterceptorFactoryProtocol? { get }
///*
/// Loads a model onto a compute unit.
func loadModel(request: SdLoadModelRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdLoadModelResponse>
}
extension SdHostModelServiceProvider {
public var serviceName: Substring {
return SdHostModelServiceServerMetadata.serviceDescriptor.fullName[...]
}
/// Determines, calls and returns the appropriate request handler, depending on the request's method.
/// Returns nil for methods not handled by this service.
public func handle(
method name: Substring,
context: CallHandlerContext
) -> GRPCServerHandlerProtocol? {
switch name {
case "LoadModel":
return UnaryServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<SdLoadModelRequest>(),
responseSerializer: ProtobufSerializer<SdLoadModelResponse>(),
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? [],
userFunction: self.loadModel(request:context:)
)
default:
return nil
}
}
}
///*
/// The model service, for management and loading of models.
///
/// To implement a server, implement an object which conforms to this protocol.
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public protocol SdHostModelServiceAsyncProvider: CallHandlerProvider, Sendable {
static var serviceDescriptor: GRPCServiceDescriptor { get }
var interceptors: SdHostModelServiceServerInterceptorFactoryProtocol? { get }
///*
/// Loads a model onto a compute unit.
func loadModel(
request: SdLoadModelRequest,
context: GRPCAsyncServerCallContext
) async throws -> SdLoadModelResponse
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdHostModelServiceAsyncProvider {
public static var serviceDescriptor: GRPCServiceDescriptor {
return SdHostModelServiceServerMetadata.serviceDescriptor
}
public var serviceName: Substring {
return SdHostModelServiceServerMetadata.serviceDescriptor.fullName[...]
}
public var interceptors: SdHostModelServiceServerInterceptorFactoryProtocol? {
return nil
}
public func handle(
method name: Substring,
context: CallHandlerContext
) -> GRPCServerHandlerProtocol? {
switch name {
case "LoadModel":
return GRPCAsyncServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<SdLoadModelRequest>(),
responseSerializer: ProtobufSerializer<SdLoadModelResponse>(),
interceptors: self.interceptors?.makeLoadModelInterceptors() ?? [],
wrapping: { try await self.loadModel(request: $0, context: $1) }
)
default:
return nil
}
}
}
public protocol SdHostModelServiceServerInterceptorFactoryProtocol: Sendable {
/// - Returns: Interceptors to use when handling 'loadModel'.
/// Defaults to calling `self.makeInterceptors()`.
func makeLoadModelInterceptors() -> [ServerInterceptor<SdLoadModelRequest, SdLoadModelResponse>]
}
public enum SdHostModelServiceServerMetadata {
public static let serviceDescriptor = GRPCServiceDescriptor(
name: "HostModelService",
fullName: "gay.pizza.stable.diffusion.HostModelService",
methods: [
SdHostModelServiceServerMetadata.Methods.loadModel,
]
)
public enum Methods {
public static let loadModel = GRPCMethodDescriptor(
name: "LoadModel",
path: "/gay.pizza.stable.diffusion.HostModelService/LoadModel",
type: GRPCCallType.unary
)
}
}