mimey 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mimey-0.1.0/Cargo.lock +208 -0
- mimey-0.1.0/Cargo.toml +13 -0
- mimey-0.1.0/PKG-INFO +7 -0
- mimey-0.1.0/pyproject.toml +15 -0
- mimey-0.1.0/src/lib.rs +22 -0
- mimey-0.1.0/uv.lock +7 -0
mimey-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "anyhow"
|
|
7
|
+
version = "1.0.100"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "autocfg"
|
|
13
|
+
version = "1.5.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "heck"
|
|
19
|
+
version = "0.5.0"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "indoc"
|
|
25
|
+
version = "2.0.6"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "libc"
|
|
31
|
+
version = "0.2.175"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "memoffset"
|
|
37
|
+
version = "0.9.1"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"autocfg",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[[package]]
|
|
45
|
+
name = "mimetype-detector"
|
|
46
|
+
version = "0.2.2"
|
|
47
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
48
|
+
checksum = "8874ffff32a3f8ef9d80e27834fb6ae005bb22c4807f088bc4ce9c649361ec42"
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "mimey"
|
|
52
|
+
version = "0.1.0"
|
|
53
|
+
dependencies = [
|
|
54
|
+
"mimetype-detector",
|
|
55
|
+
"pyo3",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[[package]]
|
|
59
|
+
name = "once_cell"
|
|
60
|
+
version = "1.21.3"
|
|
61
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
62
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
63
|
+
|
|
64
|
+
[[package]]
|
|
65
|
+
name = "portable-atomic"
|
|
66
|
+
version = "1.11.1"
|
|
67
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
68
|
+
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
|
69
|
+
|
|
70
|
+
[[package]]
|
|
71
|
+
name = "proc-macro2"
|
|
72
|
+
version = "1.0.101"
|
|
73
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
74
|
+
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
|
75
|
+
dependencies = [
|
|
76
|
+
"unicode-ident",
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
[[package]]
|
|
80
|
+
name = "pyo3"
|
|
81
|
+
version = "0.25.1"
|
|
82
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
83
|
+
checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a"
|
|
84
|
+
dependencies = [
|
|
85
|
+
"anyhow",
|
|
86
|
+
"indoc",
|
|
87
|
+
"libc",
|
|
88
|
+
"memoffset",
|
|
89
|
+
"once_cell",
|
|
90
|
+
"portable-atomic",
|
|
91
|
+
"pyo3-build-config",
|
|
92
|
+
"pyo3-ffi",
|
|
93
|
+
"pyo3-macros",
|
|
94
|
+
"serde",
|
|
95
|
+
"unindent",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "pyo3-build-config"
|
|
100
|
+
version = "0.25.1"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598"
|
|
103
|
+
dependencies = [
|
|
104
|
+
"once_cell",
|
|
105
|
+
"target-lexicon",
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
[[package]]
|
|
109
|
+
name = "pyo3-ffi"
|
|
110
|
+
version = "0.25.1"
|
|
111
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
112
|
+
checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c"
|
|
113
|
+
dependencies = [
|
|
114
|
+
"libc",
|
|
115
|
+
"pyo3-build-config",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "pyo3-macros"
|
|
120
|
+
version = "0.25.1"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"proc-macro2",
|
|
125
|
+
"pyo3-macros-backend",
|
|
126
|
+
"quote",
|
|
127
|
+
"syn",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "pyo3-macros-backend"
|
|
132
|
+
version = "0.25.1"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc"
|
|
135
|
+
dependencies = [
|
|
136
|
+
"heck",
|
|
137
|
+
"proc-macro2",
|
|
138
|
+
"pyo3-build-config",
|
|
139
|
+
"quote",
|
|
140
|
+
"syn",
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
[[package]]
|
|
144
|
+
name = "quote"
|
|
145
|
+
version = "1.0.40"
|
|
146
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
147
|
+
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
|
148
|
+
dependencies = [
|
|
149
|
+
"proc-macro2",
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
[[package]]
|
|
153
|
+
name = "serde"
|
|
154
|
+
version = "1.0.226"
|
|
155
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
156
|
+
checksum = "0dca6411025b24b60bfa7ec1fe1f8e710ac09782dca409ee8237ba74b51295fd"
|
|
157
|
+
dependencies = [
|
|
158
|
+
"serde_core",
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
[[package]]
|
|
162
|
+
name = "serde_core"
|
|
163
|
+
version = "1.0.226"
|
|
164
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
165
|
+
checksum = "ba2ba63999edb9dac981fb34b3e5c0d111a69b0924e253ed29d83f7c99e966a4"
|
|
166
|
+
dependencies = [
|
|
167
|
+
"serde_derive",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
[[package]]
|
|
171
|
+
name = "serde_derive"
|
|
172
|
+
version = "1.0.226"
|
|
173
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
174
|
+
checksum = "8db53ae22f34573731bafa1db20f04027b2d25e02d8205921b569171699cdb33"
|
|
175
|
+
dependencies = [
|
|
176
|
+
"proc-macro2",
|
|
177
|
+
"quote",
|
|
178
|
+
"syn",
|
|
179
|
+
]
|
|
180
|
+
|
|
181
|
+
[[package]]
|
|
182
|
+
name = "syn"
|
|
183
|
+
version = "2.0.106"
|
|
184
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
185
|
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
|
186
|
+
dependencies = [
|
|
187
|
+
"proc-macro2",
|
|
188
|
+
"quote",
|
|
189
|
+
"unicode-ident",
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
[[package]]
|
|
193
|
+
name = "target-lexicon"
|
|
194
|
+
version = "0.13.3"
|
|
195
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
196
|
+
checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c"
|
|
197
|
+
|
|
198
|
+
[[package]]
|
|
199
|
+
name = "unicode-ident"
|
|
200
|
+
version = "1.0.19"
|
|
201
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
202
|
+
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
|
203
|
+
|
|
204
|
+
[[package]]
|
|
205
|
+
name = "unindent"
|
|
206
|
+
version = "0.2.4"
|
|
207
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
208
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
mimey-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "mimey"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
|
+
[lib]
|
|
8
|
+
name = "mimey"
|
|
9
|
+
crate-type = ["cdylib"]
|
|
10
|
+
|
|
11
|
+
[dependencies]
|
|
12
|
+
mimetype-detector = "0.2.2"
|
|
13
|
+
pyo3 = { version = "0.25.0", features = ["anyhow", "serde", "default", "extension-module"] }
|
mimey-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.9,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mimey"
|
|
7
|
+
requires-python = ">=3.8"
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Programming Language :: Rust",
|
|
10
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
11
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
12
|
+
]
|
|
13
|
+
dynamic = ["version"]
|
|
14
|
+
[tool.maturin]
|
|
15
|
+
features = ["pyo3/extension-module"]
|
mimey-0.1.0/src/lib.rs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
use mimetype_detector::detect as internal_detect;
|
|
2
|
+
use pyo3::prelude::*;
|
|
3
|
+
|
|
4
|
+
/// Detects the mime type of a byte array.
|
|
5
|
+
#[pyfunction]
|
|
6
|
+
fn detect_mime(bytes: &[u8]) -> PyResult<String> {
|
|
7
|
+
Ok(internal_detect(bytes).mime().to_string())
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/// Detects the extension of a byte array.
|
|
11
|
+
#[pyfunction]
|
|
12
|
+
fn detect_type(bytes: &[u8]) -> PyResult<String> {
|
|
13
|
+
Ok(internal_detect(bytes).extension().to_string())
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/// A Python module implemented in Rust.
|
|
17
|
+
#[pymodule]
|
|
18
|
+
fn mimey(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
19
|
+
m.add_function(wrap_pyfunction!(detect_mime, m)?)?;
|
|
20
|
+
m.add_function(wrap_pyfunction!(detect_type, m)?)?;
|
|
21
|
+
Ok(())
|
|
22
|
+
}
|