Skip to content

Commit 5fe2cbe

Browse files
committed
Rename add_data() to add_bytes()
1 parent bb12888 commit 5fe2cbe

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

src/module_writer.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub trait ModuleWriter {
5252
/// the appropriate unix permissions
5353
///
5454
/// For generated files, `source` is `None`.
55-
fn add_data(
55+
fn add_bytes(
5656
&mut self,
5757
target: impl AsRef<Path>,
5858
source: Option<&Path>,
@@ -77,7 +77,7 @@ pub trait ModuleWriterExt: ModuleWriter {
7777

7878
let file =
7979
File::open(source).with_context(|| format!("Failed to open {}", source.display()))?;
80-
self.add_data(target, Some(source), file, executable)
80+
self.add_bytes(target, Some(source), file, executable)
8181
.with_context(|| format!("Failed to write to {}", target.display()))?;
8282
Ok(())
8383
}
@@ -101,7 +101,7 @@ pub trait ModuleWriterExt: ModuleWriter {
101101

102102
/// Creates an empty file at the specified target
103103
fn add_empty_file(&mut self, target: impl AsRef<Path>) -> Result<()> {
104-
self.add_data(target, None, io::empty(), false)
104+
self.add_bytes(target, None, io::empty(), false)
105105
}
106106
}
107107

@@ -125,7 +125,7 @@ impl PathWriter {
125125
}
126126

127127
impl ModuleWriter for PathWriter {
128-
fn add_data(
128+
fn add_bytes(
129129
&mut self,
130130
target: impl AsRef<Path>,
131131
source: Option<&Path>,
@@ -204,7 +204,7 @@ impl CompressionOptions {
204204
}
205205

206206
impl ModuleWriter for WheelWriter {
207-
fn add_data(
207+
fn add_bytes(
208208
&mut self,
209209
target: impl AsRef<Path>,
210210
source: Option<&Path>,
@@ -304,7 +304,7 @@ impl WheelWriter {
304304
let name = metadata24.get_distribution_escaped();
305305
let target = format!("{name}.pth");
306306
debug!("Adding {} from {}", target, python_path);
307-
self.add_data(target, None, python_path.as_bytes(), false)?;
307+
self.add_bytes(target, None, python_path.as_bytes(), false)?;
308308
} else {
309309
eprintln!(
310310
"⚠️ source code path contains non-Unicode sequences, editable installs may not work."
@@ -373,7 +373,7 @@ pub struct SDistWriter {
373373
}
374374

375375
impl ModuleWriter for SDistWriter {
376-
fn add_data(
376+
fn add_bytes(
377377
&mut self,
378378
target: impl AsRef<Path>,
379379
source: Option<&Path>,
@@ -923,7 +923,7 @@ pub fn write_bindings_module(
923923
} else {
924924
let module = PathBuf::from(ext_name);
925925
// Reexport the shared library as if it were the top level module
926-
writer.add_data(
926+
writer.add_bytes(
927927
module.join("__init__.py"),
928928
None,
929929
format!(
@@ -1012,13 +1012,13 @@ pub fn write_cffi_module(
10121012
};
10131013

10141014
if !editable || project_layout.python_module.is_none() {
1015-
writer.add_data(
1015+
writer.add_bytes(
10161016
module.join("__init__.py"),
10171017
None,
10181018
cffi_init_file(&cffi_module_file_name).as_bytes(),
10191019
false,
10201020
)?;
1021-
writer.add_data(
1021+
writer.add_bytes(
10221022
module.join("ffi.py"),
10231023
None,
10241024
cffi_declarations.as_bytes(),
@@ -1259,7 +1259,7 @@ pub fn write_uniffi_module(
12591259
};
12601260

12611261
if !editable || project_layout.python_module.is_none() {
1262-
writer.add_data(module.join("__init__.py"), None, py_init.as_bytes(), false)?;
1262+
writer.add_bytes(module.join("__init__.py"), None, py_init.as_bytes(), false)?;
12631263
for binding in binding_names.iter() {
12641264
writer.add_file(
12651265
module.join(binding).with_extension("py"),
@@ -1341,7 +1341,7 @@ if __name__ == '__main__':
13411341
let launcher_path = Path::new(&metadata.get_distribution_escaped())
13421342
.join(bin_name.replace('-', "_"))
13431343
.with_extension("py");
1344-
writer.add_data(&launcher_path, None, entrypoint_script.as_bytes(), true)?;
1344+
writer.add_bytes(&launcher_path, None, entrypoint_script.as_bytes(), true)?;
13451345
Ok(())
13461346
}
13471347

@@ -1428,14 +1428,14 @@ pub fn write_dist_info(
14281428
) -> Result<()> {
14291429
let dist_info_dir = metadata24.get_dist_info_dir();
14301430

1431-
writer.add_data(
1431+
writer.add_bytes(
14321432
dist_info_dir.join("METADATA"),
14331433
None,
14341434
metadata24.to_file_contents()?.as_bytes(),
14351435
false,
14361436
)?;
14371437

1438-
writer.add_data(
1438+
writer.add_bytes(
14391439
dist_info_dir.join("WHEEL"),
14401440
None,
14411441
wheel_file(tags)?.as_bytes(),
@@ -1453,7 +1453,7 @@ pub fn write_dist_info(
14531453
entry_points.push_str(&entry_points_txt(entry_type, scripts));
14541454
}
14551455
if !entry_points.is_empty() {
1456-
writer.add_data(
1456+
writer.add_bytes(
14571457
dist_info_dir.join("entry_points.txt"),
14581458
None,
14591459
entry_points.as_bytes(),
@@ -1550,7 +1550,7 @@ mod tests {
15501550
let tmp_dir = TempDir::new()?;
15511551
let mut writer = SDistWriter::new(&tmp_dir, &metadata, Override::empty(), None)?;
15521552
assert!(writer.file_tracker.0.is_empty());
1553-
writer.add_data("test", Some(Path::new("test")), empty, true)?;
1553+
writer.add_bytes("test", Some(Path::new("test")), empty, true)?;
15541554
assert_eq!(writer.file_tracker.0.len(), 1);
15551555
writer.finish()?;
15561556
tmp_dir.close()?;
@@ -1561,12 +1561,12 @@ mod tests {
15611561
excludes.add("test*")?;
15621562
excludes.add("!test2")?;
15631563
let mut writer = SDistWriter::new(&tmp_dir, &metadata, excludes.build()?, None)?;
1564-
writer.add_data("test1", Some(Path::new("test1")), empty, true)?;
1565-
writer.add_data("test3", Some(Path::new("test3")), empty, true)?;
1564+
writer.add_bytes("test1", Some(Path::new("test1")), empty, true)?;
1565+
writer.add_bytes("test3", Some(Path::new("test3")), empty, true)?;
15661566
assert!(writer.file_tracker.0.is_empty());
1567-
writer.add_data("test2", Some(Path::new("test2")), empty, true)?;
1567+
writer.add_bytes("test2", Some(Path::new("test2")), empty, true)?;
15681568
assert!(!writer.file_tracker.0.is_empty());
1569-
writer.add_data("yes", Some(Path::new("yes")), empty, true)?;
1569+
writer.add_bytes("yes", Some(Path::new("yes")), empty, true)?;
15701570
assert_eq!(writer.file_tracker.0.len(), 2);
15711571
writer.finish()?;
15721572
tmp_dir.close()?;

src/source_distribution.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ fn add_crate_to_source_distribution(
284284
let mut document = parse_toml_file(manifest_path, "Cargo.toml")?;
285285
rewrite_cargo_toml_readme(&mut document, manifest_path, readme_name)?;
286286
rewrite_cargo_toml(&mut document, manifest_path, known_path_deps)?;
287-
writer.add_data(
287+
writer.add_bytes(
288288
cargo_toml_path,
289289
Some(manifest_path),
290290
document.to_string().as_bytes(),
@@ -293,7 +293,7 @@ fn add_crate_to_source_distribution(
293293
} else if !skip_cargo_toml {
294294
let mut document = parse_toml_file(manifest_path, "Cargo.toml")?;
295295
rewrite_cargo_toml_readme(&mut document, manifest_path, readme_name)?;
296-
writer.add_data(
296+
writer.add_bytes(
297297
cargo_toml_path,
298298
Some(manifest_path),
299299
document.to_string().as_bytes(),
@@ -584,7 +584,7 @@ fn add_cargo_package_files_to_sdist(
584584
workspace_manifest_path.as_std_path(),
585585
&deps_to_keep,
586586
)?;
587-
writer.add_data(
587+
writer.add_bytes(
588588
root_dir.join(relative_workspace_cargo_toml),
589589
Some(workspace_manifest_path.as_std_path()),
590590
document.to_string().as_bytes(),
@@ -608,7 +608,7 @@ fn add_cargo_package_files_to_sdist(
608608
pyproject_toml_path,
609609
&relative_main_crate_manifest_dir.join("Cargo.toml"),
610610
)?;
611-
writer.add_data(
611+
writer.add_bytes(
612612
root_dir.join("pyproject.toml"),
613613
Some(pyproject_toml_path),
614614
rewritten_pyproject_toml.as_bytes(),
@@ -857,7 +857,7 @@ pub fn source_distribution(
857857
}
858858
}
859859

860-
writer.add_data(
860+
writer.add_bytes(
861861
root_dir.join("PKG-INFO"),
862862
None,
863863
metadata24.to_file_contents()?.as_bytes(),

tests/common/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct MockWriter {
1111
}
1212

1313
impl ModuleWriter for MockWriter {
14-
fn add_data(
14+
fn add_bytes(
1515
&mut self,
1616
target: impl AsRef<Path>,
1717
_source: Option<&Path>,

0 commit comments

Comments
 (0)