pub enum OutputSurface {
Human,
Machine,
LedgerText,
}Expand description
What kind of consumer an output surface is written for.
Decides whether thousands separators appear. The question is not “will a person read this” but does the consumer have a grammar:
- machine interchange (CSV, JSON) does not. A separator forces the
field to be quoted and is then rejected by ordinary decimal parsers —
Decimal(field)breaks (issue #1892). Suppressed unconditionally, and that suppression outranks any ledger or per-commodity declaration. - ledger text (
format,query --format beancount) does. Grouped numerals are part of Beancount syntax, so every conforming reader must accept them; the parser, not the file, is the machine boundary. Honors the ledger’s declaration (#1896). - rendered tables read by a person likewise honor it.
This exists so the rule is stated ONCE. It was previously re-derived per
writer, and the surfaces had already drifted apart: query --format beancount emitted separators into ledger text while format stripped
them, and CSV emitted them while JSON did not.
LedgerText initially suppressed them, on the premise that ledger text has
one canonical on-disk form. #1896 abandoned that premise deliberately —
rledger format --ledger now GROUPS, because a ledger that asks for
separators should get them in the file it owns — which put the two ledger
text producers back in disagreement until this arm followed. Beancount
itself groups here: grammar.py calls dcontext.set_commas(options ["render_commas"]) while parsing, and printer.py renders through that
same context.
Variants§
Human
A rendered table or report read by a person.
Machine
CSV/JSON consumed by another program.
LedgerText
Beancount source text.
Implementations§
Source§impl OutputSurface
impl OutputSurface
Sourcepub const fn renders_thousands_separators(self) -> bool
pub const fn renders_thousands_separators(self) -> bool
Whether this surface renders thousands separators when the ledger asks for them.
Only Self::Machine refuses, because only its consumers lack a
grammar that admits the separator.
Trait Implementations§
Source§impl Clone for OutputSurface
impl Clone for OutputSurface
Source§fn clone(&self) -> OutputSurface
fn clone(&self) -> OutputSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for OutputSurface
Source§impl Debug for OutputSurface
impl Debug for OutputSurface
impl Eq for OutputSurface
Source§impl PartialEq for OutputSurface
impl PartialEq for OutputSurface
impl StructuralPartialEq for OutputSurface
Auto Trait Implementations§
impl Freeze for OutputSurface
impl RefUnwindSafe for OutputSurface
impl Send for OutputSurface
impl Sync for OutputSurface
impl Unpin for OutputSurface
impl UnsafeUnpin for OutputSurface
impl UnwindSafe for OutputSurface
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.