rclone/librclone/gomobile/gomobile.go
Nick Craig-Wood ba09ee18bb librclone: factor into gomobile and internal implementation #4891
This was needed because gomobile can't use a main package wheras this
is required to make a normal shared C library.
2021-04-28 16:55:08 +01:00

41 lines
1.1 KiB
Go

// Package gomobile exports shims for gomobile use
package gomobile
import (
"github.com/rclone/rclone/librclone/librclone"
_ "github.com/rclone/rclone/backend/all" // import all backends
_ "github.com/rclone/rclone/lib/plugin" // import plugins
)
// RcloneInitialize initializes rclone as a library
func RcloneInitialize() {
librclone.Initialize()
}
// RcloneFinalize finalizes the library
func RcloneFinalize() {
librclone.Finalize()
}
// RcloneRPCResult is returned from RcloneRPC
//
// Output will be returned as a serialized JSON object
// Status is a HTTP status return (200=OK anything else fail)
type RcloneRPCResult struct {
Output string
Status int
}
// RcloneRPC has an interface optimised for gomobile, in particular
// the function signature is valid under gobind rules.
//
// https://pkg.go.dev/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions
func RcloneRPC(method string, input string) (result *RcloneRPCResult) { //nolint:deadcode
output, status := librclone.RPC(method, input)
return &RcloneRPCResult{
Output: output,
Status: status,
}
}