Extract Rust string tensor outputs safely (#32045)
This pull request adds robust support for string tensors in the ONNX
Runtime Rust bindings. It introduces new error handling for string
tensor operations, implements correct extraction and decoding of string
data, and refactors the output tensor data handling to accommodate both
borrowed and owned data. These changes ensure that string tensors are
handled safely and correctly, with clear error reporting for invalid or
unsupported operations.
**String tensor support and extraction:**
* Added new error variants to `OrtError` for string tensor-specific
failures, such as data length retrieval, content extraction, invalid
offsets, and UTF-8 decoding errors.
* Implemented `extract_string_tensor` to correctly extract and decode
string tensor data using ONNX Runtime's dedicated APIs. This includes
validation of offsets and UTF-8 content, with comprehensive error
handling.
* Updated the `OrtOutput` enum conversion to use the new string tensor
extraction logic, ensuring string tensors are properly decoded and
wrapped.
**Output tensor data handling:**
* Refactored `WithOutputTensor` to use a new `OutputTensorData` enum,
allowing it to own decoded string data or borrow numeric data, enabling
safe handling of both types.
* Modified the `view` method of `WithOutputTensor` to support both
borrowed and owned data pointers, ensuring compatibility with the new
string tensor logic.
* Prevented string tensors from being accessed through the generic
`WithOutputTensor<T>` implementation, returning a descriptive error
instead.
**Testing and validation:**
* Added unit tests for string tensor content decoding, including cases
for valid strings, empty strings, invalid offsets, and invalid UTF-8
data.