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

319 lines
11 KiB
Swift

//
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the protocol buffer compiler.
// Source: model.proto
//
import GRPC
import NIO
import NIOConcurrencyHelpers
import SwiftProtobuf
///*
/// The model service, for management and loading of models.
///
/// Usage: instantiate `SdModelServiceClient`, then call methods of this protocol to make API calls.
public protocol SdModelServiceClientProtocol: GRPCClient {
var serviceName: String { get }
var interceptors: SdModelServiceClientInterceptorFactoryProtocol? { get }
func listModels(
_ request: SdListModelsRequest,
callOptions: CallOptions?
) -> UnaryCall<SdListModelsRequest, SdListModelsResponse>
}
extension SdModelServiceClientProtocol {
public var serviceName: String {
return "gay.pizza.stable.diffusion.ModelService"
}
///*
/// Lists the available models on the host.
/// This will return both models that are currently loaded, and models that are not yet loaded.
///
/// - Parameters:
/// - request: Request to send to ListModels.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
public func listModels(
_ request: SdListModelsRequest,
callOptions: CallOptions? = nil
) -> UnaryCall<SdListModelsRequest, SdListModelsResponse> {
return self.makeUnaryCall(
path: SdModelServiceClientMetadata.Methods.listModels.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
)
}
}
@available(*, deprecated)
extension SdModelServiceClient: @unchecked Sendable {}
@available(*, deprecated, renamed: "SdModelServiceNIOClient")
public final class SdModelServiceClient: SdModelServiceClientProtocol {
private let lock = Lock()
private var _defaultCallOptions: CallOptions
private var _interceptors: SdModelServiceClientInterceptorFactoryProtocol?
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: SdModelServiceClientInterceptorFactoryProtocol? {
get { self.lock.withLock { return self._interceptors } }
set { self.lock.withLockVoid { self._interceptors = newValue } }
}
/// Creates a client for the gay.pizza.stable.diffusion.ModelService 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: SdModelServiceClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self._defaultCallOptions = defaultCallOptions
self._interceptors = interceptors
}
}
public struct SdModelServiceNIOClient: SdModelServiceClientProtocol {
public var channel: GRPCChannel
public var defaultCallOptions: CallOptions
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol?
/// Creates a client for the gay.pizza.stable.diffusion.ModelService 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: SdModelServiceClientInterceptorFactoryProtocol? = 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 SdModelServiceAsyncClientProtocol: GRPCClient {
static var serviceDescriptor: GRPCServiceDescriptor { get }
var interceptors: SdModelServiceClientInterceptorFactoryProtocol? { get }
func makeListModelsCall(
_ request: SdListModelsRequest,
callOptions: CallOptions?
) -> GRPCAsyncUnaryCall<SdListModelsRequest, SdListModelsResponse>
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdModelServiceAsyncClientProtocol {
public static var serviceDescriptor: GRPCServiceDescriptor {
return SdModelServiceClientMetadata.serviceDescriptor
}
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol? {
return nil
}
public func makeListModelsCall(
_ request: SdListModelsRequest,
callOptions: CallOptions? = nil
) -> GRPCAsyncUnaryCall<SdListModelsRequest, SdListModelsResponse> {
return self.makeAsyncUnaryCall(
path: SdModelServiceClientMetadata.Methods.listModels.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdModelServiceAsyncClientProtocol {
public func listModels(
_ request: SdListModelsRequest,
callOptions: CallOptions? = nil
) async throws -> SdListModelsResponse {
return try await self.performAsyncUnaryCall(
path: SdModelServiceClientMetadata.Methods.listModels.path,
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
interceptors: self.interceptors?.makeListModelsInterceptors() ?? []
)
}
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public struct SdModelServiceAsyncClient: SdModelServiceAsyncClientProtocol {
public var channel: GRPCChannel
public var defaultCallOptions: CallOptions
public var interceptors: SdModelServiceClientInterceptorFactoryProtocol?
public init(
channel: GRPCChannel,
defaultCallOptions: CallOptions = CallOptions(),
interceptors: SdModelServiceClientInterceptorFactoryProtocol? = nil
) {
self.channel = channel
self.defaultCallOptions = defaultCallOptions
self.interceptors = interceptors
}
}
public protocol SdModelServiceClientInterceptorFactoryProtocol: Sendable {
/// - Returns: Interceptors to use when invoking 'listModels'.
func makeListModelsInterceptors() -> [ClientInterceptor<SdListModelsRequest, SdListModelsResponse>]
}
public enum SdModelServiceClientMetadata {
public static let serviceDescriptor = GRPCServiceDescriptor(
name: "ModelService",
fullName: "gay.pizza.stable.diffusion.ModelService",
methods: [
SdModelServiceClientMetadata.Methods.listModels,
]
)
public enum Methods {
public static let listModels = GRPCMethodDescriptor(
name: "ListModels",
path: "/gay.pizza.stable.diffusion.ModelService/ListModels",
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 SdModelServiceProvider: CallHandlerProvider {
var interceptors: SdModelServiceServerInterceptorFactoryProtocol? { get }
///*
/// Lists the available models on the host.
/// This will return both models that are currently loaded, and models that are not yet loaded.
func listModels(request: SdListModelsRequest, context: StatusOnlyCallContext) -> EventLoopFuture<SdListModelsResponse>
}
extension SdModelServiceProvider {
public var serviceName: Substring {
return SdModelServiceServerMetadata.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 "ListModels":
return UnaryServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<SdListModelsRequest>(),
responseSerializer: ProtobufSerializer<SdListModelsResponse>(),
interceptors: self.interceptors?.makeListModelsInterceptors() ?? [],
userFunction: self.listModels(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 SdModelServiceAsyncProvider: CallHandlerProvider, Sendable {
static var serviceDescriptor: GRPCServiceDescriptor { get }
var interceptors: SdModelServiceServerInterceptorFactoryProtocol? { get }
///*
/// Lists the available models on the host.
/// This will return both models that are currently loaded, and models that are not yet loaded.
func listModels(
request: SdListModelsRequest,
context: GRPCAsyncServerCallContext
) async throws -> SdListModelsResponse
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension SdModelServiceAsyncProvider {
public static var serviceDescriptor: GRPCServiceDescriptor {
return SdModelServiceServerMetadata.serviceDescriptor
}
public var serviceName: Substring {
return SdModelServiceServerMetadata.serviceDescriptor.fullName[...]
}
public var interceptors: SdModelServiceServerInterceptorFactoryProtocol? {
return nil
}
public func handle(
method name: Substring,
context: CallHandlerContext
) -> GRPCServerHandlerProtocol? {
switch name {
case "ListModels":
return GRPCAsyncServerHandler(
context: context,
requestDeserializer: ProtobufDeserializer<SdListModelsRequest>(),
responseSerializer: ProtobufSerializer<SdListModelsResponse>(),
interceptors: self.interceptors?.makeListModelsInterceptors() ?? [],
wrapping: { try await self.listModels(request: $0, context: $1) }
)
default:
return nil
}
}
}
public protocol SdModelServiceServerInterceptorFactoryProtocol: Sendable {
/// - Returns: Interceptors to use when handling 'listModels'.
/// Defaults to calling `self.makeInterceptors()`.
func makeListModelsInterceptors() -> [ServerInterceptor<SdListModelsRequest, SdListModelsResponse>]
}
public enum SdModelServiceServerMetadata {
public static let serviceDescriptor = GRPCServiceDescriptor(
name: "ModelService",
fullName: "gay.pizza.stable.diffusion.ModelService",
methods: [
SdModelServiceServerMetadata.Methods.listModels,
]
)
public enum Methods {
public static let listModels = GRPCMethodDescriptor(
name: "ListModels",
path: "/gay.pizza.stable.diffusion.ModelService/ListModels",
type: GRPCCallType.unary
)
}
}