Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
[RTC-256] Add protobufs (#2)
Browse files Browse the repository at this point in the history
* remove debug method

* add lint workflow

* add workflow dispach for docs publishing

* change swift version

* Add protobufs

* update readme

* update readme
  • Loading branch information
skyman503 authored May 26, 2023
1 parent b1a6bf5 commit 040a173
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "protos"]
path = protos
url = https://github.com/jellyfish-dev/protos.git
2 changes: 1 addition & 1 deletion JellyfishClientSdk/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.7.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
4 changes: 4 additions & 0 deletions JellyfishClientSdk/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# JellyfishClientSdk

A description of this package.

# Description

API documentation is available [here](https://jellyfish-dev.github.io/ios-client-sdk/documentation/jellyfishclientsdk/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: protos/jellyfish/peer_notifications.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}

struct Jellyfish_PeerMessage {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

var content: Jellyfish_PeerMessage.OneOf_Content? = nil

var authenticated: Jellyfish_PeerMessage.Authenticated {
get {
if case .authenticated(let v)? = content {return v}
return Jellyfish_PeerMessage.Authenticated()
}
set {content = .authenticated(newValue)}
}

var authRequest: Jellyfish_PeerMessage.AuthRequest {
get {
if case .authRequest(let v)? = content {return v}
return Jellyfish_PeerMessage.AuthRequest()
}
set {content = .authRequest(newValue)}
}

var mediaEvent: Jellyfish_PeerMessage.MediaEvent {
get {
if case .mediaEvent(let v)? = content {return v}
return Jellyfish_PeerMessage.MediaEvent()
}
set {content = .mediaEvent(newValue)}
}

var unknownFields = SwiftProtobuf.UnknownStorage()

enum OneOf_Content: Equatable {
case authenticated(Jellyfish_PeerMessage.Authenticated)
case authRequest(Jellyfish_PeerMessage.AuthRequest)
case mediaEvent(Jellyfish_PeerMessage.MediaEvent)

#if !swift(>=4.1)
static func ==(lhs: Jellyfish_PeerMessage.OneOf_Content, rhs: Jellyfish_PeerMessage.OneOf_Content) -> Bool {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch (lhs, rhs) {
case (.authenticated, .authenticated): return {
guard case .authenticated(let l) = lhs, case .authenticated(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.authRequest, .authRequest): return {
guard case .authRequest(let l) = lhs, case .authRequest(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.mediaEvent, .mediaEvent): return {
guard case .mediaEvent(let l) = lhs, case .mediaEvent(let r) = rhs else { preconditionFailure() }
return l == r
}()
default: return false
}
}
#endif
}

struct Authenticated {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}
}

struct AuthRequest {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

var token: String = String()

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}
}

struct MediaEvent {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.

var data: String = String()

var unknownFields = SwiftProtobuf.UnknownStorage()

init() {}
}

init() {}
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Jellyfish_PeerMessage: @unchecked Sendable {}
extension Jellyfish_PeerMessage.OneOf_Content: @unchecked Sendable {}
extension Jellyfish_PeerMessage.Authenticated: @unchecked Sendable {}
extension Jellyfish_PeerMessage.AuthRequest: @unchecked Sendable {}
extension Jellyfish_PeerMessage.MediaEvent: @unchecked Sendable {}
#endif // swift(>=5.5) && canImport(_Concurrency)

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "jellyfish"

extension Jellyfish_PeerMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".PeerMessage"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "authenticated"),
2: .standard(proto: "auth_request"),
3: .standard(proto: "media_event"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try {
var v: Jellyfish_PeerMessage.Authenticated?
var hadOneofValue = false
if let current = self.content {
hadOneofValue = true
if case .authenticated(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
self.content = .authenticated(v)
}
}()
case 2: try {
var v: Jellyfish_PeerMessage.AuthRequest?
var hadOneofValue = false
if let current = self.content {
hadOneofValue = true
if case .authRequest(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
self.content = .authRequest(v)
}
}()
case 3: try {
var v: Jellyfish_PeerMessage.MediaEvent?
var hadOneofValue = false
if let current = self.content {
hadOneofValue = true
if case .mediaEvent(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
self.content = .mediaEvent(v)
}
}()
default: break
}
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every if/case branch local when no optimizations
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
// https://github.com/apple/swift-protobuf/issues/1182
switch self.content {
case .authenticated?: try {
guard case .authenticated(let v)? = self.content else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
}()
case .authRequest?: try {
guard case .authRequest(let v)? = self.content else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
}()
case .mediaEvent?: try {
guard case .mediaEvent(let v)? = self.content else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
}()
case nil: break
}
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Jellyfish_PeerMessage, rhs: Jellyfish_PeerMessage) -> Bool {
if lhs.content != rhs.content {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Jellyfish_PeerMessage.Authenticated: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = Jellyfish_PeerMessage.protoMessageName + ".Authenticated"
static let _protobuf_nameMap = SwiftProtobuf._NameMap()

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let _ = try decoder.nextFieldNumber() {
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Jellyfish_PeerMessage.Authenticated, rhs: Jellyfish_PeerMessage.Authenticated) -> Bool {
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Jellyfish_PeerMessage.AuthRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = Jellyfish_PeerMessage.protoMessageName + ".AuthRequest"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "token"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeSingularStringField(value: &self.token) }()
default: break
}
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.token.isEmpty {
try visitor.visitSingularStringField(value: self.token, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Jellyfish_PeerMessage.AuthRequest, rhs: Jellyfish_PeerMessage.AuthRequest) -> Bool {
if lhs.token != rhs.token {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Jellyfish_PeerMessage.MediaEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = Jellyfish_PeerMessage.protoMessageName + ".MediaEvent"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "data"),
]

mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch fieldNumber {
case 1: try { try decoder.decodeSingularStringField(value: &self.data) }()
default: break
}
}
}

func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.data.isEmpty {
try visitor.visitSingularStringField(value: self.data, fieldNumber: 1)
}
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Jellyfish_PeerMessage.MediaEvent, rhs: Jellyfish_PeerMessage.MediaEvent) -> Bool {
if lhs.data != rhs.data {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}
15 changes: 15 additions & 0 deletions compile_proto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Terminate on errors
set -e

printf "Synchronising submodules... "
git submodule sync --recursive >> /dev/null
git submodule update --recursive --remote --init >> /dev/null
printf "DONE\n\n"

file="./protos/jellyfish/peer_notifications.proto"

printf "Compiling: file $file\n"
protoc --swift_out="./JellyfishClientSdk/Sources/JellyfishClientSdk" $file
printf "DONE\n"
1 change: 1 addition & 0 deletions protos
Submodule protos added at 662095

0 comments on commit 040a173

Please sign in to comment.