Skip to content

Commit cf4f325

Browse files
authored
Bump quick-xml to 0.37.0 and remove it from public APIs (#332)
1 parent 54866ee commit cf4f325

File tree

8 files changed

+37
-41
lines changed

8 files changed

+37
-41
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
- Remove `quick_xml::Error` from the public API. [#332](https://github.com/jonhoo/inferno/pull/332)
13+
1214
### Removed
1315

1416
## [0.11.21] - 2024-08-03

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ indexmap = { version = "2.0", optional = true }
3737
itoa = "1"
3838
log = "0.4"
3939
num-format = { version = "0.4.3", default-features = false }
40-
quick-xml = { version = "0.26", default-features = false }
40+
quick-xml = { version = "0.37", default-features = false }
4141
rgb = "0.8.13"
4242
str_stack = "0.1"
4343
clap = { version = "4.0.1", optional = true, features = ["derive"] }

src/bin/flamegraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'a> Opt {
309309

310310
const PALETTE_MAP_FILE: &str = "palette.map"; // default name for the palette map file
311311

312-
fn main() -> quick_xml::Result<()> {
312+
fn main() -> io::Result<()> {
313313
let opt = Opt::parse();
314314

315315
// Initialize logger
@@ -343,7 +343,7 @@ fn main() -> quick_xml::Result<()> {
343343
)?;
344344
}
345345

346-
save_consistent_palette_if_needed(&palette_map, PALETTE_MAP_FILE).map_err(quick_xml::Error::Io)
346+
save_consistent_palette_if_needed(&palette_map, PALETTE_MAP_FILE)
347347
}
348348

349349
fn fetch_consistent_palette_if_needed(

src/flamegraph/merge.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn flow<'a, LI, TI>(
109109
pub(super) fn frames<'a, I>(
110110
lines: I,
111111
suppress_sort_check: bool,
112-
) -> quick_xml::Result<(Vec<TimedFrame<'a>>, usize, usize, usize)>
112+
) -> io::Result<(Vec<TimedFrame<'a>>, usize, usize, usize)>
113113
where
114114
I: IntoIterator<Item = &'a str>,
115115
{
@@ -128,10 +128,10 @@ where
128128
if !suppress_sort_check {
129129
if let Some(prev_line) = prev_line {
130130
if prev_line > line {
131-
return Err(quick_xml::Error::Io(io::Error::new(
131+
return Err(io::Error::new(
132132
io::ErrorKind::InvalidData,
133133
"unsorted input lines detected",
134-
)));
134+
));
135135
}
136136
}
137137
}

src/flamegraph/mod.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl Rectangle {
393393
///
394394
/// [differential flame graph]: http://www.brendangregg.com/blog/2014-11-09/differential-flame-graphs.html
395395
#[allow(clippy::cognitive_complexity)]
396-
pub fn from_lines<'a, I, W>(opt: &mut Options<'_>, lines: I, writer: W) -> quick_xml::Result<()>
396+
pub fn from_lines<'a, I, W>(opt: &mut Options<'_>, lines: I, writer: W) -> io::Result<()>
397397
where
398398
I: IntoIterator<Item = &'a str>,
399399
W: Write,
@@ -500,10 +500,10 @@ where
500500
)?;
501501
svg.write_event(Event::End(BytesEnd::new("svg")))?;
502502
svg.write_event(Event::Eof)?;
503-
return Err(quick_xml::Error::Io(io::Error::new(
503+
return Err(io::Error::new(
504504
io::ErrorKind::InvalidData,
505505
"No stack counts found",
506-
)));
506+
));
507507
}
508508

509509
let image_width = opt.image_width.unwrap_or(DEFAULT_IMAGE_WIDTH) as f64;
@@ -724,9 +724,9 @@ where
724724

725725
buffer.clear();
726726
if has_href {
727-
svg.write_event(&cache_a_end)?;
727+
svg.write_event(cache_a_end.borrow())?;
728728
} else {
729-
svg.write_event(&cache_g_end)?;
729+
svg.write_event(cache_g_end.borrow())?;
730730
}
731731
}
732732

@@ -746,7 +746,7 @@ fn write_container_start<'a, W: Write>(
746746
cache_g: &mut Event<'_>,
747747
frame: &merge::TimedFrame<'_>,
748748
mut title: &'a str,
749-
) -> quick_xml::Result<(bool, &'a str)> {
749+
) -> io::Result<(bool, &'a str)> {
750750
let frame_attributes = opt
751751
.func_frameattrs
752752
.frameattrs_for_func(frame.location.function);
@@ -755,18 +755,18 @@ fn write_container_start<'a, W: Write>(
755755
if let Some(frame_attributes) = frame_attributes {
756756
if frame_attributes.attrs.contains_key("xlink:href") {
757757
write_container_attributes(cache_a, frame_attributes);
758-
svg.write_event(cache_a)?;
758+
svg.write_event(cache_a.borrow())?;
759759
has_href = true;
760760
} else {
761761
write_container_attributes(cache_g, frame_attributes);
762-
svg.write_event(cache_g)?;
762+
svg.write_event(cache_g.borrow())?;
763763
}
764764
if let Some(ref t) = frame_attributes.title {
765765
title = t.as_str();
766766
}
767767
} else if let Event::Start(ref mut c) = cache_g {
768768
c.clear_attributes();
769-
svg.write_event(cache_g)?;
769+
svg.write_event(cache_g.borrow())?;
770770
}
771771

772772
Ok((has_href, title))
@@ -780,10 +780,10 @@ fn write_container_start<'a, W: Write>(
780780
cache_g: &mut Event<'_>,
781781
_frame: &merge::TimedFrame<'_>,
782782
title: &'a str,
783-
) -> quick_xml::Result<(bool, &'a str)> {
783+
) -> io::Result<(bool, &'a str)> {
784784
if let Event::Start(ref mut c) = cache_g {
785785
c.clear_attributes();
786-
svg.write_event(&cache_g)?;
786+
svg.write_event(cache_g.borrow())?;
787787
}
788788

789789
Ok((false, title))
@@ -810,7 +810,7 @@ fn write_container_attributes(event: &mut Event<'_>, frame_attributes: &FrameAtt
810810
/// See [`from_lines`] for the expected format of each line.
811811
///
812812
/// The resulting flame graph will be written out to `writer` in SVG format.
813-
pub fn from_reader<R, W>(opt: &mut Options<'_>, reader: R, writer: W) -> quick_xml::Result<()>
813+
pub fn from_reader<R, W>(opt: &mut Options<'_>, reader: R, writer: W) -> io::Result<()>
814814
where
815815
R: Read,
816816
W: Write,
@@ -823,17 +823,15 @@ where
823823
/// See [`from_lines`] for the expected format of each line.
824824
///
825825
/// The resulting flame graph will be written out to `writer` in SVG format.
826-
pub fn from_readers<R, W>(opt: &mut Options<'_>, readers: R, writer: W) -> quick_xml::Result<()>
826+
pub fn from_readers<R, W>(opt: &mut Options<'_>, readers: R, writer: W) -> io::Result<()>
827827
where
828828
R: IntoIterator,
829829
R::Item: Read,
830830
W: Write,
831831
{
832832
let mut input = String::new();
833833
for mut reader in readers {
834-
reader
835-
.read_to_string(&mut input)
836-
.map_err(quick_xml::Error::Io)?;
834+
reader.read_to_string(&mut input)?;
837835
}
838836
from_lines(opt, input.lines(), writer)
839837
}
@@ -842,17 +840,13 @@ where
842840
/// and write the result to provided `writer`.
843841
///
844842
/// If files is empty, STDIN will be used as input.
845-
pub fn from_files<W: Write>(
846-
opt: &mut Options<'_>,
847-
files: &[PathBuf],
848-
writer: W,
849-
) -> quick_xml::Result<()> {
843+
pub fn from_files<W: Write>(opt: &mut Options<'_>, files: &[PathBuf], writer: W) -> io::Result<()> {
850844
if files.is_empty() || files.len() == 1 && files[0].to_str() == Some("-") {
851845
let stdin = io::stdin();
852846
let r = BufReader::with_capacity(128 * 1024, stdin.lock());
853847
from_reader(opt, r, writer)
854848
} else if files.len() == 1 {
855-
let r = File::open(&files[0]).map_err(quick_xml::Error::Io)?;
849+
let r = File::open(&files[0])?;
856850
from_reader(opt, r, writer)
857851
} else {
858852
let stdin = io::stdin();
@@ -866,7 +860,7 @@ pub fn from_files<W: Write>(
866860
stdin_added = true;
867861
}
868862
} else {
869-
let r = File::open(infile).map_err(quick_xml::Error::Io)?;
863+
let r = File::open(infile)?;
870864
readers.push(Box::new(r));
871865
}
872866
}
@@ -892,7 +886,7 @@ fn filled_rectangle<W: Write>(
892886
rect: &Rectangle,
893887
color: Color,
894888
cache_rect: &mut Event<'_>,
895-
) -> quick_xml::Result<()> {
889+
) -> io::Result<()> {
896890
let x = write!(buffer, "{:.4}%", rect.x1_pct);
897891
let y = write_usize(buffer, rect.y1);
898892
let width = write!(buffer, "{:.4}%", rect.width_pct());
@@ -916,7 +910,7 @@ fn filled_rectangle<W: Write>(
916910
} else {
917911
unreachable!("cache wrapper was of wrong type: {:?}", cache_rect);
918912
}
919-
svg.write_event(cache_rect)
913+
svg.write_event(cache_rect.borrow())
920914
}
921915

922916
fn write_usize(buffer: &mut StrStack, value: usize) -> usize {

src/flamegraph/svg.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::borrow::Cow;
22
use std::cell::RefCell;
3-
use std::io::prelude::*;
3+
use std::io::{self, prelude::*};
44
use std::iter;
55

66
use quick_xml::events::{BytesCData, BytesDecl, BytesEnd, BytesStart, BytesText, Event};
@@ -59,7 +59,7 @@ pub(super) fn write_header<W>(
5959
svg: &mut Writer<W>,
6060
imageheight: usize,
6161
opt: &Options<'_>,
62-
) -> quick_xml::Result<()>
62+
) -> io::Result<()>
6363
where
6464
W: Write,
6565
{
@@ -91,7 +91,7 @@ pub(super) fn write_prelude<W>(
9191
svg: &mut Writer<W>,
9292
style_options: &StyleOptions,
9393
opt: &Options<'_>,
94-
) -> quick_xml::Result<()>
94+
) -> io::Result<()>
9595
where
9696
W: Write,
9797
{
@@ -261,7 +261,7 @@ pub(super) fn write_str<'a, W, I>(
261261
svg: &mut Writer<W>,
262262
buf: &mut StrStack,
263263
item: TextItem<'a, I>,
264-
) -> quick_xml::Result<()>
264+
) -> std::io::Result<()>
265265
where
266266
W: Write,
267267
I: IntoIterator<Item = (&'a str, &'a str)>,
@@ -290,7 +290,7 @@ where
290290
unreachable!("cache wrapper was of wrong type: {:?}", start_event);
291291
}
292292

293-
svg.write_event(&*start_event.borrow())
293+
svg.write_event(start_event.borrow().borrow())
294294
})?;
295295
let s = match text {
296296
TextArgument::String(ref s) => s,

tests/flamegraph.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn test_flamegraph(
1717
input_file: &str,
1818
expected_result_file: &str,
1919
options: Options<'_>,
20-
) -> quick_xml::Result<()> {
20+
) -> io::Result<()> {
2121
test_flamegraph_multiple_files(
2222
vec![PathBuf::from_str(input_file).unwrap()],
2323
expected_result_file,
@@ -29,7 +29,7 @@ fn test_flamegraph_multiple_files(
2929
input_files: Vec<PathBuf>,
3030
expected_result_file: &str,
3131
mut options: Options<'_>,
32-
) -> quick_xml::Result<()> {
32+
) -> io::Result<()> {
3333
// Always pretty print XML to make it easier to find differences when tests fail.
3434
options.pretty_xml = true;
3535
// Never include static JavaScript in tests so we don't have to have it duplicated
@@ -45,7 +45,7 @@ fn test_flamegraph_multiple_files(
4545
flamegraph::from_files(&mut options, &input_files, &mut f)?;
4646
fs::metadata(expected_result_file).unwrap()
4747
} else {
48-
return Err(e.into());
48+
return Err(e);
4949
}
5050
}
5151
};

0 commit comments

Comments
 (0)