Skip to content

Arbitrary fixed length arrays #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sr-gi opened this issue Dec 1, 2020 · 0 comments
Open

Arbitrary fixed length arrays #1

sr-gi opened this issue Dec 1, 2020 · 0 comments

Comments

@sr-gi
Copy link
Owner

sr-gi commented Dec 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant