Coder Social home page Coder Social logo

Comments (3)

davidcole1340 avatar davidcole1340 commented on May 27, 2024

You can use Binary<u8> as an argument for binary data. Internally it is represented (and dereferences to) a Vec<u8>. See here for more: https://davidcole1340.github.io/ext-php-rs/types/binary.html

from ext-php-rs.

cquintana92 avatar cquintana92 commented on May 27, 2024

First of all, thanks for your fast response! I have checked and indeed it works as expected 👍

Last question regarding to this issue. I've been reading through the code for Binary<T>, and it seems like it copies all the PHP memory into Rust owned memory: https://github.com/davidcole1340/ext-php-rs/blob/master/src/binary.rs#L156-L166

Would there be a way to obtain a reference to that memory without copying it? We should be able to achieve something like that by using std::slice::from_raw_parts, which converts a *const T and a length to an &[T] (it probably would only make sense to use it for &[u8].

Probably it would make sense to implement it in another trait/struct, such as BinaryRef.

Thanks!

from ext-php-rs.

cquintana92 avatar cquintana92 commented on May 27, 2024

Implemented in this PR :)

#139

from ext-php-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.