Skip to content

Arbitrary fixed length arrays #1

@sr-gi

Description

@sr-gi

Fixed length arrays up to 32-byte can be used both as parameters and return types in the current version, meaning that the inputs can be bounded at compile time without runtime checkings.

However, arrays over 32-byte long are not supported by PyO3 at the moment (should be after Rust 1.5).

For now, any array over 32-byte long implies a run time checking + an exception throwing on the Python side. e.g:

#[pymethods]
impl PyBlockHeader {
    #[new]
    fn new(data: &[u8]) -> PyResult<Self> {
        if data.len() != 80 {
            Err(exceptions::PyValueError::new_err(format!(
                "Data must be 80-byte long"
            )))
        } 
   [...]

PyO3/pyo3#1128

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions