Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Elixxir dApps SDK Swift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile
iOS
Elixxir dApps SDK Swift
Commits
6079b4de
Commit
6079b4de
authored
2 years ago
by
Dariusz Rybicki
Browse files
Options
Downloads
Patches
Plain Diff
Add FileTransferProgressCallback
parent
341a00f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!102
Release 1.0.0
,
!18
Update Bindings
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/ElixxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift
+69
-0
69 additions, 0 deletions
...xxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift
with
69 additions
and
0 deletions
Sources/ElixxirDAppsSDK/Callbacks/FileTransferProgressCallback.swift
0 → 100644
+
69
−
0
View file @
6079b4de
import
Bindings
import
XCTestDynamicOverlay
public
struct
FileTransferProgressCallback
{
public
struct
Callback
{
public
var
progress
:
Progress
public
var
partTracker
:
FilePartTracker
}
public
init
(
handle
:
@escaping
(
Result
<
Callback
,
NSError
>
)
->
Void
)
{
self
.
handle
=
handle
}
public
var
handle
:
(
Result
<
Callback
,
NSError
>
)
->
Void
}
extension
FileTransferProgressCallback
{
public
static
let
unimplemented
=
FileTransferProgressCallback
(
handle
:
XCTUnimplemented
(
"
\(
Self
.
self
)
"
)
)
}
extension
FileTransferProgressCallback
{
func
makeBindingsFileTransferReceiveProgressCallback
()
->
BindingsFileTransferReceiveProgressCallbackProtocol
{
makeBindingsFileTransferProgressCallback
(
debugName
:
"BindingsFileTransferReceiveProgressCallback"
)
}
func
makeBindingsFileTransferSentProgressCallback
()
->
BindingsFileTransferSentProgressCallbackProtocol
{
makeBindingsFileTransferProgressCallback
(
debugName
:
"BindingsFileTransferSentProgressCallback"
)
}
private
func
makeBindingsFileTransferProgressCallback
(
debugName
:
String
)
->
BindingsFileTransferReceiveProgressCallbackProtocol
&
BindingsFileTransferSentProgressCallbackProtocol
{
class
CallbackObject
:
NSObject
,
BindingsFileTransferReceiveProgressCallbackProtocol
,
BindingsFileTransferSentProgressCallbackProtocol
{
init
(
_
callback
:
FileTransferProgressCallback
,
_
debugName
:
String
)
{
self
.
callback
=
callback
self
.
debugName
=
debugName
}
let
callback
:
FileTransferProgressCallback
let
debugName
:
String
func
callback
(
_
payload
:
Data
?,
t
:
BindingsFilePartTracker
?,
err
:
Error
?)
{
if
let
error
=
err
{
callback
.
handle
(
.
failure
(
error
as
NSError
))
return
}
guard
let
payload
=
payload
else
{
fatalError
(
"
\(
debugName
)
received `nil` payload without providing error"
)
}
guard
let
tracker
=
t
else
{
fatalError
(
"
\(
debugName
)
received `nil` tracker without providing error"
)
}
do
{
callback
.
handle
(
.
success
(
.
init
(
progress
:
try
Progress
.
decode
(
payload
),
partTracker
:
.
live
(
tracker
)
)))
}
catch
{
callback
.
handle
(
.
failure
(
error
as
NSError
))
}
}
}
return
CallbackObject
(
self
,
debugName
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment