Files
navidrome/plugins/cmd/ndpgen/testdata/stream_client_expected.rs
Deluan Quintão 42c7046e9f
Pipeline: Test, Lint, Build / Get version info (push) Canceled after 0s
Pipeline: Test, Lint, Build / Lint Go code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Validate DB migrations (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go plugins (push) Canceled after 0s
Pipeline: Test, Lint, Build / Report coverage (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test Go code (Windows) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Test JS code (push) Canceled after 0s
Pipeline: Test, Lint, Build / Lint i18n files (push) Canceled after 0s
Pipeline: Test, Lint, Build / Check Docker configuration (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/386) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (linux/riscv64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (windows/386) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Canceled after 0s
Pipeline: Test, Lint, Build / Push to GHCR (push) Canceled after 0s
Pipeline: Test, Lint, Build / Push to Docker Hub () (push) Canceled after 0s
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Canceled after 0s
Pipeline: Test, Lint, Build / Build Windows installers (push) Canceled after 0s
Pipeline: Test, Lint, Build / Package/Release (push) Canceled after 0s
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Canceled after 0s
feat(plugins): generate stream support for host services in ndpgen (#6562)
2026-11-27 21:20:09 -05:00

185 lines
4.8 KiB
Rust

// Code generated by ndpgen. DO NOT EDIT.
//
// This file contains client wrappers for the Blob host service.
// It is intended for use in Navidrome plugins built with extism-pdk.
use extism_pdk::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Download {
pub size: i64,
#[serde(rename = "body", default, with = "nd_pdk_types::stream::optional")]
pub body: Option<nd_pdk_types::stream::Stream>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Upload {
pub name: String,
#[serde(rename = "body", default, with = "nd_pdk_types::stream::optional")]
pub body: Option<nd_pdk_types::stream::Stream>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct BlobOpenRequest {
name: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct BlobOpenResponse {
#[serde(rename = "result", default, with = "nd_pdk_types::stream::optional")]
result: Option<nd_pdk_types::stream::Stream>,
#[serde(default)]
error: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct BlobCreateRequest {
name: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct BlobCreateResponse {
#[serde(rename = "result", default, with = "nd_pdk_types::stream::optional")]
result: Option<nd_pdk_types::stream::Stream>,
#[serde(default)]
error: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct BlobPutRequest {
upload: Upload,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct BlobPutResponse {
#[serde(default)]
result: Option<Download>,
#[serde(default)]
error: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct BlobCopyRequest {
#[serde(rename = "src", default, with = "nd_pdk_types::stream::optional")]
src: Option<nd_pdk_types::stream::Stream>,
#[serde(rename = "dst", default, with = "nd_pdk_types::stream::optional")]
dst: Option<nd_pdk_types::stream::Stream>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
struct BlobCopyResponse {
#[serde(default)]
result: i64,
#[serde(default)]
error: Option<String>,
}
#[link(wasm_import_module = "extism:host/user")]
extern "C" {
fn blob_open(input: u64) -> u64;
fn blob_create(input: u64) -> u64;
fn blob_put(input: u64) -> u64;
fn blob_copy(input: u64) -> u64;
}
/// Calls the blob_open host function.
///
/// # Arguments
/// * `name` - String parameter.
///
/// # Returns
/// The result value.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn open(name: &str) -> Result<Option<nd_pdk_types::stream::Stream>, Error> {
let response: BlobOpenResponse = unsafe { nd_pdk_types::hostcall::call(blob_open, &BlobOpenRequest {
name: name.to_owned(),
}) }?;
if let Some(err) = response.error {
return Err(Error::msg(err));
}
Ok(response.result)
}
/// Calls the blob_create host function.
///
/// # Arguments
/// * `name` - String parameter.
///
/// # Returns
/// The result value.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn create(name: &str) -> Result<Option<nd_pdk_types::stream::Stream>, Error> {
let response: BlobCreateResponse = unsafe { nd_pdk_types::hostcall::call(blob_create, &BlobCreateRequest {
name: name.to_owned(),
}) }?;
if let Some(err) = response.error {
return Err(Error::msg(err));
}
Ok(response.result)
}
/// Calls the blob_put host function.
///
/// # Arguments
/// * `upload` - Upload parameter.
///
/// # Returns
/// The result value.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn put(upload: Upload) -> Result<Option<Download>, Error> {
let response: BlobPutResponse = unsafe { nd_pdk_types::hostcall::call(blob_put, &BlobPutRequest {
upload: upload,
}) }?;
if let Some(err) = response.error {
return Err(Error::msg(err));
}
Ok(response.result)
}
/// Calls the blob_copy host function.
///
/// # Arguments
/// * `src` - Option<nd_pdk_types::stream::Stream> parameter.
/// * `dst` - Option<nd_pdk_types::stream::Stream> parameter.
///
/// # Returns
/// The result value.
///
/// # Errors
/// Returns an error if the host function call fails.
pub fn copy(src: Option<nd_pdk_types::stream::Stream>, dst: Option<nd_pdk_types::stream::Stream>) -> Result<i64, Error> {
let response: BlobCopyResponse = unsafe { nd_pdk_types::hostcall::call(blob_copy, &BlobCopyRequest {
src: src,
dst: dst,
}) }?;
if let Some(err) = response.error {
return Err(Error::msg(err));
}
Ok(response.result)
}