diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-06 02:21:52 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-03-06 04:13:45 -0500 |
commit | ea1b618203d7dfa9a24aa2b5a80085f860594b9c (patch) | |
tree | 63ceac6de2f723ba545809eb575037cbc0a334c2 /rust-src/bch_bindgen/src/lib.rs | |
parent | 0206d42daf4c4bd3bbcfa15a2bef34319524db49 (diff) |
cmd_list.rs: Finish list modes, delete cmd_list.c
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src/bch_bindgen/src/lib.rs')
-rw-r--r-- | rust-src/bch_bindgen/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rust-src/bch_bindgen/src/lib.rs b/rust-src/bch_bindgen/src/lib.rs index d2b58511..86592c6b 100644 --- a/rust-src/bch_bindgen/src/lib.rs +++ b/rust-src/bch_bindgen/src/lib.rs @@ -157,3 +157,13 @@ impl FromStr for c::bpos { Ok(c::bpos { inode: ino, offset: off, snapshot: snp }) } } + +pub fn printbuf_to_formatter<F>(f: &mut fmt::Formatter<'_>, func: F) -> fmt::Result + where F: Fn(*mut c::printbuf) { + let mut buf = c::printbuf::new(); + + func(&mut buf); + + let s = unsafe { CStr::from_ptr(buf.buf) }; + f.write_str(s.to_str().unwrap()) +} |