R7S2CWF72WQTE447Q62PKCVJSSCEXHMVUJ33Z6IN6NREOUSD4WNQC
2JBFREZGJ2PST2DE3ZVDQADXAOFXBYPMSFTG7C65GDKLOZGETTGAC
YDK6X6PPD42DMLFGF6OO2O3G7GA4Z2PCIDJIREHX6XNX2NYEBJSQC
UESS5YZE6ZHPMVUL2P2OACW2Y2QLFLLLLC3F3JAENVH6A7REKLBAC
M7VINXOFAKFTEKQZR3RFO3WJQ3RXE2TWD4YAVKTPLMJWC4LISTIQC
I2P2FTLEKLICJKHQ3FHOLRQRQYGZCJTCTU2MWXU2TMIRIKG6YFCQC
ND7GASJ45SLCZWNTZVAEQOWRF4HQ4GQ7TQLQZ4CUTW2IW3JN776QC
5S4MZHL5SO3D3M2CNQESORNJ47QCX7X7SPTO3K63VDXMITYMRZBQC
ONRIF4V72HMVLO4BWDHI7ZOWYWTLTVYNH5TXUN5HB7BQUMV22NVAC
QRIJE4AQWN7A7O2CO7FXRV4FXZ5RHONQKRGHYXAD7WSECJYK2MFAC
NSWL54NMMYELYDQNRFAO7S6GBFDW6MDJ5TM2EYMK2VX336DGACHQC
D6UTHZA4XNAR2PTG4YEZFNNH3OTSNOWGDSVBYDRE5R2YSV7MPN6AC
MYQI5JIDJP6UII4UQFCZDR4VKKZJ3RRLWMS2WTALQGPKS43577FAC
pub fn join(self, segment: impl AsRef<str>) -> Result<Self, AccountError> {
fn join_inner(mut this: Account, segment: &str) -> Result<Account, AccountError> {
ensure!(
is_valid_account_segment(segment),
AccountSnafu { name: segment }
);
this.name.push(':');
this.name.push_str(segment);
pub fn join(self, segment: impl AsRef<Seg>) -> Self {
let mut this = self;
impl TryFrom<&Seg> for Account {
type Error = <Self as TryFrom<&'static str>>::Error;
fn try_from(segment: &Seg) -> Result<Self, Self::Error> {
Self::try_from(&segment.inner)
}
}
impl TryFrom<Segment> for Account {
type Error = <Self as TryFrom<String>>::Error;
fn try_from(segment: Segment) -> Result<Self, Self::Error> {
Self::try_from(segment.inner)
}
}
}
}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Seg {
inner: str,
}
impl Seg {
/// Create a new `Seg` from a `str` without validating the name before.
///
/// # Safety
///
/// Other functions on this type assume that `name` is a valid account name, as defined by beancount.
/// You must ensure that this is the case.
/// See [`is_valid_account_segment`] for a function providing that guarantee.
#[allow(unsafe_code)]
const unsafe fn from_unchecked(name: &str) -> &Self {
unsafe {
// SAFETY: Seg is repr(transparent), so it has the same representation as a str, which makes the cast safe.
let name: *const _ = name;
let name = name as *const _;
&*name
}
}
}
impl AsRef<str> for Seg {
#[inline]
fn as_ref(&self) -> &str {
self.borrow()
}
}
impl AsRef<Self> for Seg {
#[inline]
fn as_ref(&self) -> &Self {
self
}
}
impl Borrow<str> for Seg {
#[inline]
fn borrow(&self) -> &str {
self
}
}
impl Deref for Seg {
type Target = str;
#[inline]
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl Display for Seg {
delegate! {
to self.inner {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result;
}
}
}
impl PartialEq<&str> for Seg {
#[inline]
fn eq(&self, other: &&str) -> bool {
self.eq(*other)
}
}
impl PartialEq<Cow<'_, Self>> for Seg {
#[inline]
fn eq(&self, other: &Cow<'_, Seg>) -> bool {
self.eq(&**other)
}
}
impl PartialEq<Cow<'_, str>> for Seg {
#[inline]
fn eq(&self, other: &Cow<'_, str>) -> bool {
self.eq(&**other)
}
}
impl PartialEq<Seg> for &str {
#[inline]
fn eq(&self, other: &Seg) -> bool {
other.eq(self)
}
}
impl PartialEq<Seg> for Cow<'_, Seg> {
#[inline]
fn eq(&self, other: &Seg) -> bool {
other.eq(self)
}
}
impl PartialEq<Seg> for Cow<'_, str> {
#[inline]
fn eq(&self, other: &Seg) -> bool {
other.eq(self)
}
}
impl PartialEq<Seg> for String {
#[inline]
fn eq(&self, other: &Seg) -> bool {
other.eq(self)
}
}
impl PartialEq<Seg> for str {
#[inline]
fn eq(&self, other: &Seg) -> bool {
other.eq(self)
}
}
impl PartialEq<String> for Seg {
#[inline]
fn eq(&self, other: &String) -> bool {
self.eq(&**other)
}
}
impl PartialEq<str> for Seg {
#[inline]
fn eq(&self, other: &str) -> bool {
self.partial_cmp(other).map_or(false, Ordering::is_eq)
}
}
impl PartialOrd<Cow<'_, Self>> for Seg {
#[inline]
fn partial_cmp(&self, other: &Cow<'_, Seg>) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<Cow<'_, str>> for Seg {
#[inline]
fn partial_cmp(&self, other: &Cow<'_, str>) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<Seg> for &str {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Seg> for Cow<'_, Seg> {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Seg> for Cow<'_, str> {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Seg> for String {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Seg> for str {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<String> for Seg {
#[inline]
fn partial_cmp(&self, other: &String) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<&str> for Seg {
#[inline]
fn partial_cmp(&self, other: &&str) -> Option<Ordering> {
self.partial_cmp(*other)
}
}
impl PartialOrd<str> for Seg {
#[inline]
fn partial_cmp(&self, other: &str) -> Option<Ordering> {
self.inner.partial_cmp(other)
}
}
impl ToOwned for Seg {
type Owned = Segment;
#[inline]
fn to_owned(&self) -> Self::Owned {
self.into()
}
}
impl<'s> TryFrom<&'s str> for &'s Seg {
type Error = SegmentError;
fn try_from(segment: &'s str) -> Result<Self, Self::Error> {
ensure!(is_valid_account_segment(segment), SegmentSnafu { segment });
Ok(
#[allow(unsafe_code)]
unsafe {
// SAFETY: we have ensured that `value` is valid.
Seg::from_unchecked(segment)
},
)
}
}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct Segment {
inner: String,
}
impl AsRef<Seg> for Segment {
#[inline]
fn as_ref(&self) -> &Seg {
self.borrow()
}
}
impl AsRef<str> for Segment {
#[inline]
fn as_ref(&self) -> &str {
self
}
}
impl Borrow<Seg> for Segment {
#[inline]
fn borrow(&self) -> &Seg {
self
}
}
impl Deref for Segment {
type Target = Seg;
#[inline]
fn deref(&self) -> &Self::Target {
#[allow(unsafe_code)]
unsafe {
// SAFETY: `self` is a valid `Segment`, therefore `self.inner` is a valid segment, by construction.
Self::Target::from_unchecked(&self.inner)
}
}
}
impl Display for Segment {
delegate! {
to self.inner {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result;
}
}
}
impl From<&Seg> for Segment {
#[inline]
fn from(seg: &Seg) -> Self {
let inner = seg.inner.into();
Self { inner }
}
}
impl PartialEq<&str> for Segment {
#[inline]
fn eq(&self, other: &&str) -> bool {
self.eq(*other)
}
}
impl PartialEq<Cow<'_, Seg>> for Segment {
#[inline]
fn eq(&self, other: &Cow<'_, Seg>) -> bool {
self.eq(&**other)
}
}
impl PartialEq<Cow<'_, str>> for Segment {
#[inline]
fn eq(&self, other: &Cow<'_, str>) -> bool {
self.eq(&**other)
}
}
impl PartialEq<Seg> for Segment {
#[inline]
fn eq(&self, other: &Seg) -> bool {
(**self).eq(other)
}
}
impl PartialEq<Segment> for &str {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<Segment> for Cow<'_, Seg> {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<Segment> for Cow<'_, str> {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<Segment> for Seg {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<Segment> for String {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<Segment> for str {
#[inline]
fn eq(&self, other: &Segment) -> bool {
other.eq(self)
}
}
impl PartialEq<String> for Segment {
#[inline]
fn eq(&self, other: &String) -> bool {
self.eq(&**other)
}
}
impl PartialEq<str> for Segment {
#[inline]
fn eq(&self, other: &str) -> bool {
self.partial_cmp(other).map_or(false, Ordering::is_eq)
}
}
impl PartialOrd<Cow<'_, Seg>> for Segment {
#[inline]
fn partial_cmp(&self, other: &Cow<'_, Seg>) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<Cow<'_, str>> for Segment {
#[inline]
fn partial_cmp(&self, other: &Cow<'_, str>) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<Seg> for Segment {
#[inline]
fn partial_cmp(&self, other: &Seg) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Segment> for &str {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Segment> for Cow<'_, Seg> {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
impl PartialOrd<Segment> for Cow<'_, str> {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Segment> for Seg {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Segment> for String {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<Segment> for str {
#[inline]
fn partial_cmp(&self, other: &Segment) -> Option<Ordering> {
other.partial_cmp(self)
}
}
impl PartialOrd<String> for Segment {
#[inline]
fn partial_cmp(&self, other: &String) -> Option<Ordering> {
self.partial_cmp(&**other)
}
}
impl PartialOrd<&str> for Segment {
#[inline]
fn partial_cmp(&self, other: &&str) -> Option<Ordering> {
self.partial_cmp(*other)
}
}
impl PartialOrd<str> for Segment {
#[inline]
fn partial_cmp(&self, other: &str) -> Option<Ordering> {
(*self.inner).partial_cmp(other)
}
}
impl TryFrom<&str> for Segment {
type Error = <&'static Seg as TryFrom<&'static str>>::Error;
#[inline]
fn try_from(name: &str) -> Result<Self, Self::Error> {
<&Seg>::try_from(name).map(Self::from)
}
}
impl TryFrom<String> for Segment {
type Error = <Self as TryFrom<&'static str>>::Error;
#[inline]
fn try_from(segment: String) -> Result<Self, Self::Error> {
ensure!(is_valid_account_segment(&segment), SegmentSnafu { segment });
Ok(Self { inner: segment })
}
}
#[derive(Debug, Diagnostic, Snafu)]
#[snafu(display("invalid account segment: {segment:?}"))]
pub struct SegmentError {
segment: String,
backtrace: Backtrace,
}
delegate! {
to self.inner {
fn next_back(&mut self) -> Option<Self::Item>;
}
fn next_back(&mut self) -> Option<Self::Item> {
self.inner.next_back().map(|seg| {
#[allow(unsafe_code)]
unsafe {
// SAFETY: `self` is a valid `Acc`, therefore each `seg` is a valid segment, by construction.
Seg::from_unchecked(seg)
}
})
delegate! {
to self.inner {
fn next(&mut self) -> Option<Self::Item>;
}
fn next(&mut self) -> Option<Self::Item> {
self.inner.next().map(|seg| {
#[allow(unsafe_code)]
unsafe {
// SAFETY: `self` is a valid `Acc`, therefore each `seg` is a valid segment, by construction.
Seg::from_unchecked(seg)
}
})
checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b"
checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf"
[[package]]
name = "beancount-importers-framework"
version = "0.0.0-dev.0"
dependencies = [
"beancount-pretty-printer",
"beancount-tree-writer",
"beancount-types",
"camino",
"clap",
"clap-verbosity-flag",
"color-eyre",
"ebase",
"inventory",
"maplit",
"miette",
"ron",
"serde",
"tracing",
"tracing-error",
"tracing-log",
"tracing-subscriber",
"uniondepot",
]
]
[[package]]
name = "clap"
version = "4.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"once_cell",
"strsim",
"termcolor",
]
[[package]]
name = "clap-verbosity-flag"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e2b6c3dcdb73299f48ae05b294da14e2f560b3ed2c09e742269eb1b22af231"
dependencies = [
"clap",
"log",
]
[[package]]
name = "clap_derive"
version = "4.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "csv"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
dependencies = [
"bstr 0.2.17",
"csv-core",
"itoa 0.4.8",
"ryu",
"serde",
]
[[package]]
name = "csv-core"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90"
dependencies = [
"memchr",
]
[[package]]
name = "ctor"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "cxx"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a"
dependencies = [
"cc",
"cxxbridge-flags",
"cxxbridge-macro",
"link-cplusplus",
]
[[package]]
name = "cxx-build"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827"
dependencies = [
"cc",
"codespan-reporting",
"once_cell",
"proc-macro2",
"quote",
"scratch",
"syn",
]
[[package]]
name = "cxxbridge-flags"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a"
[[package]]
name = "cxxbridge-macro"
version = "1.0.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7"
dependencies = [
"proc-macro2",
"quote",
"syn",
checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "itoa"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
]
[[package]]
name = "miette"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28d6092d7e94a90bb9ea8e6c26c99d5d112d49dda2afdb4f7ea8cf09e1a5a6d"
dependencies = [
"atty",
"backtrace",
"miette-derive",
"once_cell",
"owo-colors",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"terminal_size",
"textwrap",
"thiserror",
"unicode-width",
]
[[package]]
name = "miette-derive"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f2485ed7d1fe80704928e3eb86387439609bd0c6bb96db8208daa364cfd1e09"
dependencies = [
"proc-macro2",
"quote",
"syn",
name = "os_str_bytes"
version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "supports-color"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4872ced36b91d47bae8a214a683fe54e7078875b399dfa251df346c9b547d1f9"
dependencies = [
"atty",
"is_ci",
]
[[package]]
name = "supports-hyperlinks"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406"
dependencies = [
"atty",
]
[[package]]
name = "supports-unicode"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2"
dependencies = [
"atty",
]
[[package]]
checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "unicode-linebreak"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137"
dependencies = [
"hashbrown 0.12.3",
"regex",
]
]
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc 0.42.0",
"windows_i686_gnu 0.42.0",
"windows_i686_msvc 0.42.0",
"windows_x86_64_gnu 0.42.0",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc 0.42.0",
name = "windows_x86_64_gnu"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]