xdg-mime-rs

Rust crate for querying the shared-mime-info database

APACHE-2.0 License

Downloads
54.3K
Stars
13
Committers
5
xdg-mime-rs - xdg-mime 0.3.3 Latest Release

Published by ebassi over 3 years ago

Changes from 0.3.2

  • Switched to dirs-next to replace the now abandoned dirs crate (#24, veeshi)
  • Dropped the last few nom macro uses
  • Return text/plain for desktop files with no extensions, as a security precaution
xdg-mime-rs - xdg_mime 0.3.2

Published by ebassi over 4 years ago

Quick bug fix release.

When loading the shared-mime info database from multiple locations we might end up loading the same data. When there are multiple globs matching with the same type, we might end up in a confusing situation, and break the MIME type guessing.

Bugs fixed

  • #19: Unable to guess text/turtle type
xdg-mime-rs - xdg_mime 0.3.1

Published by ebassi over 4 years ago

New stable release, improving the code to be more idiomatic and less "hey, this is the first real Rust project of a C programmer".

Bugs fixed

  • #15 - Replace for loops with iterators [Federico Mena Quintero]
  • #18 - Fix the name of the crate in the documentation
  • #17 - Return the sniffed MIME type in case of conflicts decided by the superclass
xdg-mime-rs - xdg_mime 0.3.0

Published by ebassi over 4 years ago

This is the first real stable release of the xdg_mime crate.

API changes from 0.2

  • The Guess.mime_type method now returns a reference to the mime::Mime instance, instead of a copy.

New features

  • The GuessBuilder type acquired new methods to improve the MIME type detection:
  • metadata: pass a std::fs::Metadata object of a file; this allows us to detect directories, executable files, or empty files
  • path: pass a Path reference to a file; this allows us to automatically fill up the other fields when calling the guess method
  • improve content sniffing for files that do not match any glob rule, but are either empty or contain only text
  • detect the inode/symlink MIME type

Bug fixes

  • We now correctly match magic rules at the same grouping level (#13)
xdg-mime-rs - xdg_mime 0.2.1 (preview)

Published by ebassi over 4 years ago

Bug fix release.

Contains a fix in the MIME content matching code which prevented, among other things, to determine the MIME type of shell scripts. See: #13

xdg-mime-rs - xdg_mime 0.2.0 (preview)

Published by ebassi over 4 years ago

Another preview release of the xdg_mime crate.

The API is definitely stabler, but I reserve the right to tweak it to
conform to the Rust style guidelines, and especially in light of
feedback received from external users.

New functionality in this release

  • added the SharedMimeInfo.reload method, which allows you to reload
    the contents of the shared MIME database, in case it changed. This is
    mostly useful for long-running processes that might end up surviving
    a system update.
  • added the SharedMimeInfo.guess_mime_type method, which allows you
    to guess the MIME type of a file or a chunk of data, following the
    appropriate checking algorithm outlined in the shared-mime-info
    specification.
  • lots of improvements in the documentation, including examples.
xdg-mime-rs - xdg_mime 0.1.0 (preview)

Published by ebassi over 4 years ago

Initial release of the xdg_mime crate.

You should consider this a "preview" release; the API hasn't been
finalized, yet, but I consider this the minimum safe set of symbols to
expose for the time being.

Basic functionality

  • load the system shared-mime database
  • get the list of possible MIME types for a file name
  • get the MIME type for a chunk of data
  • compare two MIME types for equality, including aliases
  • look up icon names for a given MIME type
  • look up all the parent types for a MIME type

Planned future improvements

  • better documentation
  • more examples
  • an implementation of the recommended checking algorithm as
    defined by the shared-mime-info specification
  • explicit database reloading
  • memory mapped mime.cache support

Further improvements

  • MIME type handlers
  • accessing the XML data
Package Rankings
Top 15.17% on Crates.io
Badges
Extracted from project README
crates.io docs.rs