Giter Site home page Giter Site logo

Comments (9)

polyfloyd avatar polyfloyd commented on July 30, 2024 1

The underlying storage abstraction does support in-memory buffers. I'll see how this can be nicely exposed :)

Thank you for the suggestion!

from rust-id3.

polyfloyd avatar polyfloyd commented on July 30, 2024 1

Good! I will be releasing this in v1.10 then

from rust-id3.

polyfloyd avatar polyfloyd commented on July 30, 2024

I have pushed possible implementation in the expose-storage-file branch. Could you please check whether this does what you expect it to do?

from rust-id3.

DCNick3 avatar DCNick3 commented on July 30, 2024

Yep, it seems to work for me!

However there are some other APIs that do still can't operate in-memory:

Specifically, I was using id3::v1v2::write_to_path to not only set the id3v2 tag, but also to remove the v1 tag. Internally it uses id3::v1::Tag::remove, which doesn't seem to use the FileStorage trait and operates on File directly..

Then there are all the id3::Tag::write_to_* APIs, but they seem to be already covered by the Encoder. Is there any difference between those APIs?

from rust-id3.

skabber avatar skabber commented on July 30, 2024

I don't know if this helps but I was able to get around this by using a Cursor

use std::io::Cursor;

let curs = Cursor::new(&mut bytes_of_mp3);

// tag is an id3::tag::Tag
tag.write_to(curs, Version::Id3v23).unwrap();

// you can then get the bytes and do what you like with them
let bytes = b.as_slice();

from rust-id3.

polyfloyd avatar polyfloyd commented on July 30, 2024

@skabber That works to get the raw ID3 tag, but write_to does not take into account any existing data. So if the newly written tag is larger than any existing tag, the data coming after will be partially overwritten!

write_to_path is aware of the size the tag and trailing data and does not have this problem. But this API does currently not permit writing to in-memory buffers, which is what this issue is about :)

from rust-id3.

polyfloyd avatar polyfloyd commented on July 30, 2024

@DCNick3 I have updated the patch to introduce a write_to_file family of functions everywhere. Please check again

from rust-id3.

skabber avatar skabber commented on July 30, 2024

@skabber That works to get the raw ID3 tag, but write_to does not take into account any existing data. So if the newly written tag is larger than any existing tag, the data coming after will be partially overwritten!

write_to_path is aware of the size the tag and trailing data and does not have this problem. But this API does currently not permit writing to in-memory buffers, which is what this issue is about :)

Thank you. You may have just exposed a bug in my project :)

from rust-id3.

DCNick3 avatar DCNick3 commented on July 30, 2024

@polyfloyd

@DCNick3 I have updated the patch to introduce a write_to_file family of functions everywhere. Please check again

Yep, this seems to work nicely!

from rust-id3.

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.