// Code generated by ndpgen. DO NOT EDIT. // // This file contains client wrappers for the Artwork host service. // It is intended for use in Navidrome plugins built with TinyGo. // //go:build wasip1 package host import ( "encoding/json" "errors" "github.com/navidrome/navidrome/plugins/pdk/go/pdk" ) // artwork_getartisturl is the host function provided by Navidrome. // //go:wasmimport extism:host/user artwork_getartisturl func artwork_getartisturl(uint64) uint64 // artwork_getalbumurl is the host function provided by Navidrome. // //go:wasmimport extism:host/user artwork_getalbumurl func artwork_getalbumurl(uint64) uint64 // artwork_gettrackurl is the host function provided by Navidrome. // //go:wasmimport extism:host/user artwork_gettrackurl func artwork_gettrackurl(uint64) uint64 // artwork_getplaylisturl is the host function provided by Navidrome. // //go:wasmimport extism:host/user artwork_getplaylisturl func artwork_getplaylisturl(uint64) uint64 type artworkGetArtistUrlRequest struct { Id string `json:"id"` Size int32 `json:"size"` } type artworkGetArtistUrlResponse struct { Url string `json:"url,omitempty"` Error string `json:"error,omitempty"` } type artworkGetAlbumUrlRequest struct { Id string `json:"id"` Size int32 `json:"size"` } type artworkGetAlbumUrlResponse struct { Url string `json:"url,omitempty"` Error string `json:"error,omitempty"` } type artworkGetTrackUrlRequest struct { Id string `json:"id"` Size int32 `json:"size"` } type artworkGetTrackUrlResponse struct { Url string `json:"url,omitempty"` Error string `json:"error,omitempty"` } type artworkGetPlaylistUrlRequest struct { Id string `json:"id"` Size int32 `json:"size"` } type artworkGetPlaylistUrlResponse struct { Url string `json:"url,omitempty"` Error string `json:"error,omitempty"` } // ArtworkGetArtistUrl calls the artwork_getartisturl host function. // GetArtistUrl generates a public URL for an artist's artwork. // // Parameters: // - id: The artist's unique identifier // - size: Desired image size in pixels (0 for original size) // // Returns the public URL for the artwork, or an error if generation fails. func ArtworkGetArtistUrl(id string, size int32) (string, error) { // Marshal request to JSON req := artworkGetArtistUrlRequest{ Id: id, Size: size, } reqBytes, err := json.Marshal(req) if err != nil { return "", err } reqMem := pdk.AllocateBytes(reqBytes) defer reqMem.Free() // Call the host function responsePtr := artwork_getartisturl(reqMem.Offset()) // Read the response from memory responseMem := pdk.FindMemory(responsePtr) responseBytes := responseMem.ReadBytes() // Parse the response var response artworkGetArtistUrlResponse if err := json.Unmarshal(responseBytes, &response); err != nil { return "", err } // Convert Error field to Go error if response.Error != "" { return "", errors.New(response.Error) } return response.Url, nil } // ArtworkGetAlbumUrl calls the artwork_getalbumurl host function. // GetAlbumUrl generates a public URL for an album's artwork. // // Parameters: // - id: The album's unique identifier // - size: Desired image size in pixels (0 for original size) // // Returns the public URL for the artwork, or an error if generation fails. func ArtworkGetAlbumUrl(id string, size int32) (string, error) { // Marshal request to JSON req := artworkGetAlbumUrlRequest{ Id: id, Size: size, } reqBytes, err := json.Marshal(req) if err != nil { return "", err } reqMem := pdk.AllocateBytes(reqBytes) defer reqMem.Free() // Call the host function responsePtr := artwork_getalbumurl(reqMem.Offset()) // Read the response from memory responseMem := pdk.FindMemory(responsePtr) responseBytes := responseMem.ReadBytes() // Parse the response var response artworkGetAlbumUrlResponse if err := json.Unmarshal(responseBytes, &response); err != nil { return "", err } // Convert Error field to Go error if response.Error != "" { return "", errors.New(response.Error) } return response.Url, nil } // ArtworkGetTrackUrl calls the artwork_gettrackurl host function. // GetTrackUrl generates a public URL for a track's artwork. // // Parameters: // - id: The track's (media file) unique identifier // - size: Desired image size in pixels (0 for original size) // // Returns the public URL for the artwork, or an error if generation fails. func ArtworkGetTrackUrl(id string, size int32) (string, error) { // Marshal request to JSON req := artworkGetTrackUrlRequest{ Id: id, Size: size, } reqBytes, err := json.Marshal(req) if err != nil { return "", err } reqMem := pdk.AllocateBytes(reqBytes) defer reqMem.Free() // Call the host function responsePtr := artwork_gettrackurl(reqMem.Offset()) // Read the response from memory responseMem := pdk.FindMemory(responsePtr) responseBytes := responseMem.ReadBytes() // Parse the response var response artworkGetTrackUrlResponse if err := json.Unmarshal(responseBytes, &response); err != nil { return "", err } // Convert Error field to Go error if response.Error != "" { return "", errors.New(response.Error) } return response.Url, nil } // ArtworkGetPlaylistUrl calls the artwork_getplaylisturl host function. // GetPlaylistUrl generates a public URL for a playlist's artwork. // // Parameters: // - id: The playlist's unique identifier // - size: Desired image size in pixels (0 for original size) // // Returns the public URL for the artwork, or an error if generation fails. func ArtworkGetPlaylistUrl(id string, size int32) (string, error) { // Marshal request to JSON req := artworkGetPlaylistUrlRequest{ Id: id, Size: size, } reqBytes, err := json.Marshal(req) if err != nil { return "", err } reqMem := pdk.AllocateBytes(reqBytes) defer reqMem.Free() // Call the host function responsePtr := artwork_getplaylisturl(reqMem.Offset()) // Read the response from memory responseMem := pdk.FindMemory(responsePtr) responseBytes := responseMem.ReadBytes() // Parse the response var response artworkGetPlaylistUrlResponse if err := json.Unmarshal(responseBytes, &response); err != nil { return "", err } // Convert Error field to Go error if response.Error != "" { return "", errors.New(response.Error) } return response.Url, nil }