//go:build wasip1

// Code generated by protoc-gen-go-plugin. DO NOT EDIT.
// versions:
// 	protoc-gen-go-plugin v0.1.0
// 	protoc               v5.29.3
// source: api/api.proto

package api

import (
	context "context"
	wasm "github.com/knqyf263/go-plugin/wasm"
)

const MetadataAgentPluginAPIVersion = 1

//go:wasmexport metadata_agent_api_version
func _metadata_agent_api_version() uint64 {
	return MetadataAgentPluginAPIVersion
}

var metadataAgent MetadataAgent

func RegisterMetadataAgent(p MetadataAgent) {
	metadataAgent = p
}

//go:wasmexport metadata_agent_get_artist_mbid
func _metadata_agent_get_artist_mbid(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistMBIDRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetArtistMBID(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_artist_url
func _metadata_agent_get_artist_url(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistURLRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetArtistURL(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_artist_biography
func _metadata_agent_get_artist_biography(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistBiographyRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetArtistBiography(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_similar_artists
func _metadata_agent_get_similar_artists(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistSimilarRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetSimilarArtists(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_artist_images
func _metadata_agent_get_artist_images(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistImageRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetArtistImages(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_artist_top_songs
func _metadata_agent_get_artist_top_songs(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ArtistTopSongsRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetArtistTopSongs(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_album_info
func _metadata_agent_get_album_info(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(AlbumInfoRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetAlbumInfo(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport metadata_agent_get_album_images
func _metadata_agent_get_album_images(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(AlbumImagesRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := metadataAgent.GetAlbumImages(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

const ScrobblerPluginAPIVersion = 1

//go:wasmexport scrobbler_api_version
func _scrobbler_api_version() uint64 {
	return ScrobblerPluginAPIVersion
}

var scrobbler Scrobbler

func RegisterScrobbler(p Scrobbler) {
	scrobbler = p
}

//go:wasmexport scrobbler_is_authorized
func _scrobbler_is_authorized(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ScrobblerIsAuthorizedRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := scrobbler.IsAuthorized(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport scrobbler_now_playing
func _scrobbler_now_playing(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ScrobblerNowPlayingRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := scrobbler.NowPlaying(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport scrobbler_scrobble
func _scrobbler_scrobble(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(ScrobblerScrobbleRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := scrobbler.Scrobble(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

const SchedulerCallbackPluginAPIVersion = 1

//go:wasmexport scheduler_callback_api_version
func _scheduler_callback_api_version() uint64 {
	return SchedulerCallbackPluginAPIVersion
}

var schedulerCallback SchedulerCallback

func RegisterSchedulerCallback(p SchedulerCallback) {
	schedulerCallback = p
}

//go:wasmexport scheduler_callback_on_scheduler_callback
func _scheduler_callback_on_scheduler_callback(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(SchedulerCallbackRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := schedulerCallback.OnSchedulerCallback(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

const LifecycleManagementPluginAPIVersion = 1

//go:wasmexport lifecycle_management_api_version
func _lifecycle_management_api_version() uint64 {
	return LifecycleManagementPluginAPIVersion
}

var lifecycleManagement LifecycleManagement

func RegisterLifecycleManagement(p LifecycleManagement) {
	lifecycleManagement = p
}

//go:wasmexport lifecycle_management_on_init
func _lifecycle_management_on_init(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(InitRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := lifecycleManagement.OnInit(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

const WebSocketCallbackPluginAPIVersion = 1

//go:wasmexport web_socket_callback_api_version
func _web_socket_callback_api_version() uint64 {
	return WebSocketCallbackPluginAPIVersion
}

var webSocketCallback WebSocketCallback

func RegisterWebSocketCallback(p WebSocketCallback) {
	webSocketCallback = p
}

//go:wasmexport web_socket_callback_on_text_message
func _web_socket_callback_on_text_message(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(OnTextMessageRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := webSocketCallback.OnTextMessage(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport web_socket_callback_on_binary_message
func _web_socket_callback_on_binary_message(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(OnBinaryMessageRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := webSocketCallback.OnBinaryMessage(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport web_socket_callback_on_error
func _web_socket_callback_on_error(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(OnErrorRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := webSocketCallback.OnError(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}

//go:wasmexport web_socket_callback_on_close
func _web_socket_callback_on_close(ptr, size uint32) uint64 {
	b := wasm.PtrToByte(ptr, size)
	req := new(OnCloseRequest)
	if err := req.UnmarshalVT(b); err != nil {
		return 0
	}
	response, err := webSocketCallback.OnClose(context.Background(), req)
	if err != nil {
		ptr, size = wasm.ByteToPtr([]byte(err.Error()))
		return (uint64(ptr) << uint64(32)) | uint64(size) |
			// Indicate that this is the error string by setting the 32-th bit, assuming that
			// no data exceeds 31-bit size (2 GiB).
			(1 << 31)
	}

	b, err = response.MarshalVT()
	if err != nil {
		return 0
	}
	ptr, size = wasm.ByteToPtr(b)
	return (uint64(ptr) << uint64(32)) | uint64(size)
}
