"""Auto-generated by bindgen. Do not edit."""
# ruff: noqa: E501, F401, I001
# fmt: off

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, ClassVar, Optional, TYPE_CHECKING, Union

from wasmtime.component import Variant as _WitVariant
from wasmtime.component import VariantCase as _WitVariantCase


class Error:
    """A resource which represents some error information.

The only method provided by this resource is `to-debug-string`,
which provides some human-readable information about the error.

In the `wasi:io` package, this resource is returned through the
`wasi:io/streams/stream-error` type.

To provide more specific error information, other interfaces may
offer functions to "downcast" this error into more specific types. For example,
errors returned from streams derived from filesystem types can be described using
the filesystem's own error-code type. This is done using the function
`wasi:filesystem/types/filesystem-error-code`, which takes a `borrow<error>`
parameter and returns an `option<wasi:filesystem/types/error-code>`.

The set of functions which can "downcast" an `error` into a more
concrete type is open."""
    # Wraps a wasmtime-py ResourceAny / ResourceHost handle.
    # The runtime sets ._handle to the underlying resource and
    # ._invoke to a callable that dispatches a method by WIT name.

    def __init__(self, handle: Any, invoke: Any = None) -> None:
        self._handle = handle
        self._invoke = invoke

    def to_debug_string(self) -> str:
        return self._invoke('[method]error.to-debug-string', (self._handle,))
