global: snapshot

This commit is contained in:
nym21
2026-03-07 15:23:12 +01:00
parent bcebf1cdc5
commit d4faedfba1
88 changed files with 521 additions and 302 deletions
Generated
+2
View File
@@ -3291,12 +3291,14 @@ checksum = "8f54a172d0620933a27a4360d3db3e2ae0dd6cceae9730751a036bbf182c4b23"
name = "vecdb" name = "vecdb"
version = "0.6.8" version = "0.6.8"
dependencies = [ dependencies = [
"itoa",
"libc", "libc",
"log", "log",
"lz4_flex 0.12.0", "lz4_flex 0.12.0",
"parking_lot", "parking_lot",
"pco", "pco",
"rawdb", "rawdb",
"ryu",
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
+2 -2
View File
@@ -62,8 +62,8 @@ impl fmt::Display for AnyAddressIndex {
impl Formattable for AnyAddressIndex { impl Formattable for AnyAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+3 -4
View File
@@ -164,9 +164,8 @@ impl std::fmt::Display for BasisPoints16 {
impl Formattable for BasisPoints16 { impl Formattable for BasisPoints16 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -137,9 +137,8 @@ impl std::fmt::Display for BasisPoints32 {
impl Formattable for BasisPoints32 { impl Formattable for BasisPoints32 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
@@ -160,9 +160,8 @@ impl std::fmt::Display for BasisPointsSigned16 {
impl Formattable for BasisPointsSigned16 { impl Formattable for BasisPointsSigned16 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
@@ -166,9 +166,8 @@ impl std::fmt::Display for BasisPointsSigned32 {
impl Formattable for BasisPointsSigned32 { impl Formattable for BasisPointsSigned32 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -143,9 +143,8 @@ impl std::fmt::Display for Bitcoin {
impl Formattable for Bitcoin { impl Formattable for Bitcoin {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -39,9 +39,8 @@ impl std::fmt::Display for BlkPosition {
impl Formattable for BlkPosition { impl Formattable for BlkPosition {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+10 -3
View File
@@ -93,9 +93,16 @@ impl<'de> Deserialize<'de> for BlockHash {
} }
impl Formattable for BlockHash { impl Formattable for BlockHash {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+3 -4
View File
@@ -282,9 +282,8 @@ impl std::fmt::Display for Cents {
impl Formattable for Cents { impl Formattable for Cents {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -114,10 +114,9 @@ impl Div<usize> for CentsSats {
impl Formattable for CentsSats { impl Formattable for CentsSats {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -261,9 +261,8 @@ impl std::fmt::Display for CentsSigned {
impl Formattable for CentsSigned { impl Formattable for CentsSigned {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -109,10 +109,9 @@ impl Div<usize> for CentsSquaredSats {
impl Formattable for CentsSquaredSats { impl Formattable for CentsSquaredSats {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+10 -3
View File
@@ -260,10 +260,17 @@ impl FromStr for Date {
} }
impl Formattable for Date { impl Formattable for Date {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+3 -4
View File
@@ -216,9 +216,8 @@ impl fmt::Display for Day1 {
impl Formattable for Day1 { impl Formattable for Day1 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Day3 {
impl Formattable for Day3 { impl Formattable for Day3 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -110,10 +110,9 @@ impl std::fmt::Display for DifficultyEpoch {
impl Formattable for DifficultyEpoch { impl Formattable for DifficultyEpoch {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -434,9 +434,8 @@ impl std::fmt::Display for Dollars {
impl Formattable for Dollars { impl Formattable for Dollars {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+14 -2
View File
@@ -49,16 +49,28 @@ impl std::fmt::Display for EmptyAddressData {
} }
impl Formattable for EmptyAddressData { impl Formattable for EmptyAddressData {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for EmptyAddressData { impl Bytes for EmptyAddressData {
+2 -2
View File
@@ -82,7 +82,7 @@ impl std::fmt::Display for EmptyAddressIndex {
impl Formattable for EmptyAddressIndex { impl Formattable for EmptyAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+2 -2
View File
@@ -79,7 +79,7 @@ impl fmt::Display for EmptyOutputIndex {
impl Formattable for EmptyOutputIndex { impl Formattable for EmptyOutputIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+3 -4
View File
@@ -122,9 +122,8 @@ impl std::fmt::Display for FeeRate {
impl Formattable for FeeRate { impl Formattable for FeeRate {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+14 -2
View File
@@ -169,16 +169,28 @@ impl std::fmt::Display for FundedAddressData {
} }
impl Formattable for FundedAddressData { impl Formattable for FundedAddressData {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for FundedAddressData { impl Bytes for FundedAddressData {
+2 -2
View File
@@ -78,7 +78,7 @@ impl std::fmt::Display for FundedAddressIndex {
impl Formattable for FundedAddressIndex { impl Formattable for FundedAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+3 -4
View File
@@ -116,10 +116,9 @@ impl std::fmt::Display for HalvingEpoch {
impl Formattable for HalvingEpoch { impl Formattable for HalvingEpoch {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -286,10 +286,9 @@ impl std::fmt::Display for Height {
impl Formattable for Height { impl Formattable for Height {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Hour1 {
impl Formattable for Hour1 { impl Formattable for Hour1 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Hour12 {
impl Formattable for Hour12 { impl Formattable for Hour12 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Hour4 {
impl Formattable for Hour4 { impl Formattable for Hour4 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Minute10 {
impl Formattable for Minute10 { impl Formattable for Minute10 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -81,9 +81,8 @@ impl std::fmt::Display for Minute30 {
impl Formattable for Minute30 { impl Formattable for Minute30 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -135,9 +135,8 @@ impl std::fmt::Display for Month1 {
impl Formattable for Month1 { impl Formattable for Month1 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -129,9 +129,8 @@ impl std::fmt::Display for Month3 {
impl Formattable for Month3 { impl Formattable for Month3 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -121,9 +121,8 @@ impl std::fmt::Display for Month6 {
impl Formattable for Month6 { impl Formattable for Month6 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+82 -18
View File
@@ -128,16 +128,28 @@ impl Display for OHLCCents {
} }
impl Formattable for OHLCCents { impl Formattable for OHLCCents {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for OHLCCents { impl Bytes for OHLCCents {
@@ -259,16 +271,28 @@ impl Display for OHLCDollars {
} }
impl Formattable for OHLCDollars { impl Formattable for OHLCDollars {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for OHLCDollars { impl Bytes for OHLCDollars {
@@ -359,16 +383,28 @@ impl Display for OHLCSats {
} }
impl Formattable for OHLCSats { impl Formattable for OHLCSats {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for OHLCSats { impl Bytes for OHLCSats {
@@ -518,10 +554,17 @@ impl<T> Formattable for Open<T>
where where
T: Display, T: Display,
{ {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
@@ -650,10 +693,17 @@ impl<T> Formattable for High<T>
where where
T: Display, T: Display,
{ {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
@@ -782,10 +832,17 @@ impl<T> Formattable for Low<T>
where where
T: Display, T: Display,
{ {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
@@ -937,9 +994,16 @@ impl<T> Formattable for Close<T>
where where
T: Display, T: Display,
{ {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+2 -2
View File
@@ -84,7 +84,7 @@ impl std::fmt::Display for OpReturnIndex {
impl Formattable for OpReturnIndex { impl Formattable for OpReturnIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+20 -6
View File
@@ -144,10 +144,17 @@ impl Bytes for OracleBins {
} }
impl Formattable for OracleBins { impl Formattable for OracleBins {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
@@ -300,9 +307,16 @@ impl Bytes for OracleBinsV2 {
} }
impl Formattable for OracleBinsV2 { impl Formattable for OracleBinsV2 {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+14 -2
View File
@@ -47,16 +47,28 @@ impl std::fmt::Display for OutPoint {
} }
impl Formattable for OutPoint { impl Formattable for OutPoint {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Serialize for OutPoint { impl Serialize for OutPoint {
+10 -3
View File
@@ -205,10 +205,17 @@ impl TryFrom<OutputType> for AddressType {
} }
impl Formattable for OutputType { impl Formattable for OutputType {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2AAddressIndex {
impl Formattable for P2AAddressIndex { impl Formattable for P2AAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2ABytes {
} }
impl Formattable for P2ABytes { impl Formattable for P2ABytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -84,7 +84,7 @@ impl std::fmt::Display for P2MSOutputIndex {
impl Formattable for P2MSOutputIndex { impl Formattable for P2MSOutputIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2PK33AddressIndex {
impl Formattable for P2PK33AddressIndex { impl Formattable for P2PK33AddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2PK33Bytes {
} }
impl Formattable for P2PK33Bytes { impl Formattable for P2PK33Bytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -104,7 +104,7 @@ impl std::fmt::Display for P2PK65AddressIndex {
impl Formattable for P2PK65AddressIndex { impl Formattable for P2PK65AddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2PK65Bytes {
} }
impl Formattable for P2PK65Bytes { impl Formattable for P2PK65Bytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2PKHAddressIndex {
impl Formattable for P2PKHAddressIndex { impl Formattable for P2PKHAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2PKHBytes {
} }
impl Formattable for P2PKHBytes { impl Formattable for P2PKHBytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -112,7 +112,7 @@ impl std::fmt::Display for P2SHAddressIndex {
impl Formattable for P2SHAddressIndex { impl Formattable for P2SHAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2SHBytes {
} }
impl Formattable for P2SHBytes { impl Formattable for P2SHBytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2TRAddressIndex {
impl Formattable for P2TRAddressIndex { impl Formattable for P2TRAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2TRBytes {
} }
impl Formattable for P2TRBytes { impl Formattable for P2TRBytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2WPKHAddressIndex {
impl Formattable for P2WPKHAddressIndex { impl Formattable for P2WPKHAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2WPKHBytes {
} }
impl Formattable for P2WPKHBytes { impl Formattable for P2WPKHBytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+2 -2
View File
@@ -105,7 +105,7 @@ impl std::fmt::Display for P2WSHAddressIndex {
impl Formattable for P2WSHAddressIndex { impl Formattable for P2WSHAddressIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+14 -2
View File
@@ -44,14 +44,26 @@ impl fmt::Display for P2WSHBytes {
} }
impl Formattable for P2WSHBytes { impl Formattable for P2WSHBytes {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+3 -4
View File
@@ -115,9 +115,8 @@ impl std::fmt::Display for PairOutputIndex {
impl Formattable for PairOutputIndex { impl Formattable for PairOutputIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+10 -3
View File
@@ -410,10 +410,17 @@ impl PoolSlug {
} }
impl Formattable for PoolSlug { impl Formattable for PoolSlug {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+14 -2
View File
@@ -38,14 +38,26 @@ impl std::fmt::Display for RawLockTime {
} }
impl Formattable for RawLockTime { impl Formattable for RawLockTime {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
+3 -4
View File
@@ -346,9 +346,8 @@ impl std::fmt::Display for Sats {
impl Formattable for Sats { impl Formattable for Sats {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -214,9 +214,8 @@ impl std::fmt::Display for SatsSigned {
impl Formattable for SatsSigned { impl Formattable for SatsSigned {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -188,10 +188,9 @@ impl std::fmt::Display for SatsFract {
impl Formattable for SatsFract { impl Formattable for SatsFract {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+2 -3
View File
@@ -70,8 +70,7 @@ impl std::fmt::Display for StoredBool {
impl Formattable for StoredBool { impl Formattable for StoredBool {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
f.push_str(if self.is_true() { "true" } else { "false" }); buf.extend_from_slice(if self.is_true() { b"true" } else { b"false" });
Ok(())
} }
} }
+3 -4
View File
@@ -273,9 +273,8 @@ impl std::fmt::Display for StoredF32 {
impl Formattable for StoredF32 { impl Formattable for StoredF32 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -246,9 +246,8 @@ impl std::fmt::Display for StoredF64 {
impl Formattable for StoredF64 { impl Formattable for StoredF64 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = ryu::Buffer::new(); let mut b = ryu::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -117,9 +117,8 @@ impl std::fmt::Display for StoredI16 {
impl Formattable for StoredI16 { impl Formattable for StoredI16 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -132,9 +132,8 @@ impl std::fmt::Display for StoredI64 {
impl Formattable for StoredI64 { impl Formattable for StoredI64 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -117,9 +117,8 @@ impl std::fmt::Display for StoredI8 {
impl Formattable for StoredI8 { impl Formattable for StoredI8 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -208,9 +208,8 @@ impl std::fmt::Display for StoredU16 {
impl Formattable for StoredU16 { impl Formattable for StoredU16 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -260,9 +260,8 @@ impl std::fmt::Display for StoredU32 {
impl Formattable for StoredU32 { impl Formattable for StoredU32 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -275,9 +275,8 @@ impl std::fmt::Display for StoredU64 {
impl Formattable for StoredU64 { impl Formattable for StoredU64 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -108,9 +108,8 @@ impl std::fmt::Display for StoredU8 {
impl Formattable for StoredU8 { impl Formattable for StoredU8 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+14 -2
View File
@@ -82,16 +82,28 @@ impl fmt::Display for SupplyState {
} }
impl Formattable for SupplyState { impl Formattable for SupplyState {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
use std::fmt::Write; use std::fmt::Write;
let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
let start = f.len(); let start = f.len();
write!(f, "{}", self)?; self.fmt_into(f);
if f.as_bytes()[start..].contains(&b',') { if f.as_bytes()[start..].contains(&b',') {
f.insert(start, '"'); f.insert(start, '"');
f.push('"'); f.push('"');
} }
Ok(()) Ok(())
} }
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
}
} }
impl Bytes for SupplyState { impl Bytes for SupplyState {
+3 -4
View File
@@ -189,9 +189,8 @@ impl std::fmt::Display for Timestamp {
impl Formattable for Timestamp { impl Formattable for Timestamp {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+10 -3
View File
@@ -84,9 +84,16 @@ impl<'de> Deserialize<'de> for Txid {
} }
impl Formattable for Txid { impl Formattable for Txid {
#[inline(always)] fn write_to(&self, buf: &mut Vec<u8>) {
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result {
use std::fmt::Write; use std::fmt::Write;
write!(f, "{}", self) let mut s = String::new();
write!(s, "{}", self).unwrap();
buf.extend_from_slice(s.as_bytes());
}
fn fmt_json(&self, buf: &mut Vec<u8>) {
buf.push(b'"');
self.write_to(buf);
buf.push(b'"');
} }
} }
+3 -4
View File
@@ -170,9 +170,8 @@ impl std::fmt::Display for TxIndex {
impl Formattable for TxIndex { impl Formattable for TxIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -131,9 +131,8 @@ impl std::fmt::Display for TxInIndex {
impl Formattable for TxInIndex { impl Formattable for TxInIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -132,9 +132,8 @@ impl std::fmt::Display for TxOutIndex {
impl Formattable for TxOutIndex { impl Formattable for TxOutIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -65,9 +65,8 @@ impl std::fmt::Display for TxVersion {
impl Formattable for TxVersion { impl Formattable for TxVersion {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -147,9 +147,8 @@ impl std::fmt::Display for TypeIndex {
impl Formattable for TypeIndex { impl Formattable for TypeIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+2 -2
View File
@@ -79,7 +79,7 @@ impl std::fmt::Display for UnknownOutputIndex {
impl Formattable for UnknownOutputIndex { impl Formattable for UnknownOutputIndex {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
self.0.fmt_csv(f) self.0.write_to(buf);
} }
} }
+3 -4
View File
@@ -98,9 +98,8 @@ impl std::fmt::Display for Vout {
impl Formattable for Vout { impl Formattable for Vout {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -121,9 +121,8 @@ impl std::fmt::Display for VSize {
impl Formattable for VSize { impl Formattable for VSize {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -145,9 +145,8 @@ impl std::fmt::Display for Week1 {
impl Formattable for Week1 { impl Formattable for Week1 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -137,9 +137,8 @@ impl std::fmt::Display for Weight {
impl Formattable for Weight { impl Formattable for Weight {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -124,9 +124,8 @@ impl std::fmt::Display for Year {
impl Formattable for Year { impl Formattable for Year {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -142,9 +142,8 @@ impl std::fmt::Display for Year1 {
impl Formattable for Year1 { impl Formattable for Year1 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }
+3 -4
View File
@@ -144,9 +144,8 @@ impl std::fmt::Display for Year10 {
impl Formattable for Year10 { impl Formattable for Year10 {
#[inline(always)] #[inline(always)]
fn fmt_csv(&self, f: &mut String) -> std::fmt::Result { fn write_to(&self, buf: &mut Vec<u8>) {
let mut buf = itoa::Buffer::new(); let mut b = itoa::Buffer::new();
f.push_str(buf.format(self.0)); buf.extend_from_slice(b.format(self.0).as_bytes());
Ok(())
} }
} }