pub struct Document {
pub version: u32,
pub kind: DocumentKind,
pub title: String,
pub components: Vec<Component>,
pub wires: Vec<Wire>,
pub junctions: BTreeSet<Point>,
pub labels: Vec<Label>,
pub board: Board,
pub no_connects: Vec<Terminal>,
pub power_flags: Vec<Terminal>,
pub board_zone: Option<Point>,
pub zones: Vec<SheetZone>,
}Fields§
§version: u32§kind: DocumentKind§title: String§components: Vec<Component>§wires: Vec<Wire>§junctions: BTreeSet<Point>§labels: Vec<Label>§board: BoardPhysical layout. Absent in version 1-3 documents.
no_connects: Vec<Terminal>Pins the user marked as meant to be left open: the electrical rule check
(Document::erc) does not ask for them to be connected. Omitted when
empty, so a document without markers reads as it did before they existed.
power_flags: Vec<Terminal>Pins carrying a power flag, KiCad’s PWR_FLAG: the net they are on is driven from off the sheet, so its power inputs are not reported undriven.
board_zone: Option<Point>A wiring diagram kept beside a board’s schematic only: where, in this
diagram’s coordinates, the board’s schematic origin sits when the two are
drawn as one sheet (sheet). Absent until the diagram is first written
from a sheet, so every older diagram reads and writes as it did.
zones: Vec<SheetZone>The boards of their own this assembly places (sub-board zones, sheet). A
wiring diagram stores where each one’s schematic is drawn on the sheet, by
occurrence, once it has been written from a sheet; a sheet holds each one with
its parts and nets, read-only. Never on a schematic.
Implementations§
Source§impl Document
impl Document
Sourcepub fn set_pin_function(
&mut self,
id: Uuid,
number: &str,
function: Option<&str>,
) -> Result<bool, String>
pub fn set_pin_function( &mut self, id: Uuid, number: &str, function: Option<&str>, ) -> Result<bool, String>
Choose which function component id’s pin number goes by: one of the
pin’s Pin::alternates, or its main name (None, or the main name
itself), which clears the choice. Documentary only; see
Pin::alternates. Returns whether anything changed.
Source§impl Document
impl Document
Sourcepub fn autoroute(&mut self) -> RouteOutcome
pub fn autoroute(&mut self) -> RouteOutcome
Route every unrouted connection and add the copper to the board.
Source§impl Document
impl Document
Sourcepub fn fill_zones(&mut self) -> Vec<ZoneReport>
pub fn fill_zones(&mut self) -> Vec<ZoneReport>
Fill every zone of the board against the schematic’s nets.
Source§impl Document
impl Document
Sourcepub fn sync_board(&mut self) -> BoardSync
pub fn sync_board(&mut self) -> BoardSync
Place each new component with its part’s pads and drop the placements of
removed components. Existing placements are kept. A component with no pads is
left off the board and listed in BoardSync::without_pads: pads come with
the part, from a KiCad import or the pads editor, never from a generator.
Sourcepub fn place_by_nets(&mut self)
pub fn place_by_nets(&mut self)
Lay every part out afresh by its nets: the part with the most pins in the
middle of the board, then each part, in Self::placement_order, in the free
room nearest the parts already laid out that it shares a small net with. Each
keeps its side and its rotation. Where the room runs out the rest are packed
in rows below, as Self::auto_place packs them, and the outline grows.
Self::auto_place packs the same order into rows, so a part’s neighbours
were the ones beside it in the row and the next row began at the left edge
however far that was from them (the eCAD re-audit’s B10).
Sourcepub fn auto_place(&mut self)
pub fn auto_place(&mut self)
Pack all placements in rows inside the outline, keeping connected parts together.
Sourcepub fn fit_board_outline(&mut self, margin: i32)
pub fn fit_board_outline(&mut self, margin: i32)
Resize a rectangular outline around all courtyards with a margin.
Sourcepub fn track_nets(&self) -> BTreeMap<Uuid, String>
pub fn track_nets(&self) -> BTreeMap<Uuid, String>
The schematic net each drawn track carries, for the tracks whose copper island carries exactly one. A track joined to nothing, or bridging two nets, has none.
Sourcepub fn apply_net_widths(&mut self) -> usize
pub fn apply_net_widths(&mut self) -> usize
Give every drawn track the width its net asks for, or the default width where its net has no rule of its own. Tracks whose width was set by hand keep it. Returns how many tracks changed. Widening copper can break clearances, so run the design rule check afterwards.
Sourcepub fn set_track_width(&mut self, id: Uuid, width: i32) -> Result<(), String>
pub fn set_track_width(&mut self, id: Uuid, width: i32) -> Result<(), String>
Set one track’s width, whatever its net asks for. Document::apply_net_widths
then leaves this track alone until Document::follow_net_width gives it back.
Sourcepub fn follow_net_width(&mut self, id: Uuid)
pub fn follow_net_width(&mut self, id: Uuid)
Hand one track back to its net’s width rule.
pub fn board_drc(&self) -> Vec<Violation>
Source§impl Document
impl Document
Sourcepub fn erc(&self) -> Vec<ErcFinding>
pub fn erc(&self) -> Vec<ErcFinding>
Run the electrical rule check. Errors first, then warnings, each in sheet order. A wiring diagram has no nets and so no findings.
Sourcepub fn apply_erc_fix(&mut self, fix: &ErcFix)
pub fn apply_erc_fix(&mut self, fix: &ErcFix)
Make the edit a finding offers.
Source§impl Document
impl Document
Sourcepub fn fabrication(&self, name: &str) -> Result<Fabrication, String>
pub fn fabrication(&self, name: &str) -> Result<Fabrication, String>
Gerber and drill files for the board. name prefixes every file name.
Sourcepub fn pick_and_place_csv(&self) -> String
pub fn pick_and_place_csv(&self) -> String
The pick-and-place (centroid) file, one row per placed part, in the
column convention of JLCPCB’s CPL template, which KiCad’s own position
export and most assembly houses also accept:
Designator,Val,Package,Mid X,Mid Y,Rotation,Layer.
- Mid X / Mid Y are the footprint’s anchor (its origin, where KiCad puts a
part’s position), in millimetres with a
mmsuffix, from the Gerbers’ own origin: the outline’s lower-left corner, Y up. - Rotation is in degrees, counter-clockwise as seen from the top, 0 to 270. A bottom part is reported the same way: the angle of its mirrored footprint seen from the top. No assembler-specific bottom-side correction is applied.
- Layer is
ToporBottom.
Rows are in reference order (R2 before R10). Power symbols have no
part to place and do not appear.
Sourcepub fn electronics_bom_csv(&self) -> String
pub fn electronics_bom_csv(&self) -> String
The electronics bill of materials: one line per value and footprint,
with every reference that uses it, in the column convention of JLCPCB’s
BOM template: Comment,Designator,Footprint,Quantity. Comment is the
part’s value, as JLCPCB names it; Designator lists the references in
order (R1,R2,R10), quoted because it holds commas.
Every component on the schematic is listed, placed on the board or not: a part not yet on the board still has to be bought. Its footprint is the one it would be placed with. Power symbols are not parts and are left out. Lines are in the order of their first reference.
Source§impl Document
impl Document
Sourcepub fn is_harness(&self, wire: &Wire) -> bool
pub fn is_harness(&self, wire: &Wire) -> bool
Whether wire is a harness wire, by this document’s kind.
Sourcepub fn on_board(&self, component: &Component) -> bool
pub fn on_board(&self, component: &Component) -> bool
Whether component is on the board, by this document’s kind.
Sourcepub fn net_reaches(&self, terminal: &Terminal) -> Result<(), String>
pub fn net_reaches(&self, terminal: &Terminal) -> Result<(), String>
Whether a net may reach terminal: on a sheet, only a pin of a part on the
board. The refusal names the part.
Sourcepub fn harness_reaches(&self, terminal: &Terminal) -> Result<(), String>
pub fn harness_reaches(&self, terminal: &Terminal) -> Result<(), String>
Whether a harness wire may end on terminal: anywhere but a pin inside a
sub-board the board declares no point for. The refusal names the pin and says
what to do.
Sourcepub fn zone_member(&self, id: Uuid) -> Option<&SheetZone>
pub fn zone_member(&self, id: Uuid) -> Option<&SheetZone>
The sub-board zone a part of the sheet is drawn from.
Sourcepub fn zone_of_net(&self, id: Uuid) -> Option<&SheetZone>
pub fn zone_of_net(&self, id: Uuid) -> Option<&SheetZone>
The sub-board zone a net of the sheet is drawn from.
Sourcepub fn without_zones(&self) -> Document
pub fn without_zones(&self) -> Document
This sheet with its sub-board zones left out: its own board’s parts, nets and markers, and the parts off any board. What its nets and its check read.
Sourcepub fn sub_zone_extent(&self, occurrence: &str) -> Option<(Point, Point)>
pub fn sub_zone_extent(&self, occurrence: &str) -> Option<(Point, Point)>
The box round a sub-board zone’s parts: None for one with none.
Sourcepub fn move_zone(&mut self, occurrence: &str, by: Point) -> Result<(), String>
pub fn move_zone(&mut self, occurrence: &str, by: Point) -> Result<(), String>
Move a sub-board zone, its parts and nets with it, and the harness wire ends on them.
Sourcepub fn zone_edit_refusal(&self, before: &Document) -> Option<String>
pub fn zone_edit_refusal(&self, before: &Document) -> Option<String>
Why the edit from before to self is refused: it changed a sub-board’s parts
or nets other than by moving the whole zone. They are the board’s own document,
read-only on this sheet until the zone is entered (step 3).
Sourcepub fn board_zone_extent(&self) -> Option<(Point, Point)>
pub fn board_zone_extent(&self) -> Option<(Point, Point)>
The parts on the board, as the zone drawn round them spans the sheet: None
when none is.
Sourcepub fn set_off_board(&mut self, id: Uuid, off_board: bool) -> Result<(), String>
pub fn set_off_board(&mut self, id: Uuid, off_board: bool) -> Result<(), String>
Put a part of a sheet on the board (off_board == false) or take it off.
Taking it off lets go of everything of the board’s that holds its pins (net wire ends, net flags, no-connect and power-flag markers); its harness wires stay. A part placed from an assembly part that has no pads is refused entry, with the reason, because the board could not seat it.
Sourcepub fn merge_sheet(
pcb: Option<Document>,
diagram: Option<Document>,
offset: Option<Point>,
) -> Result<(Document, SheetSource), String>
pub fn merge_sheet( pcb: Option<Document>, diagram: Option<Document>, offset: Option<Point>, ) -> Result<(Document, SheetSource), String>
Read a board’s schematic and a wiring diagram into one sheet. offset is where
the host last drew the diagram this session (the schematic origin, in diagram
coordinates); the diagram’s own Document::board_zone wins over it, and
with neither the diagram is put to the left of the board.
Sourcepub fn merge_sheet_with(
pcb: Option<Document>,
diagram: Option<Document>,
offset: Option<Point>,
boards: Vec<SubBoard>,
) -> Result<(Document, SheetSource), String>
pub fn merge_sheet_with( pcb: Option<Document>, diagram: Option<Document>, offset: Option<Point>, boards: Vec<SubBoard>, ) -> Result<(Document, SheetSource), String>
Document::merge_sheet for an assembly that places boards of its own: each
is a zone of the sheet, drawn from its schematic where the diagram’s
Document::zones say, else beside everything else.
Sourcepub fn split_sheet(&self, source: &SheetSource) -> Result<SplitSheet, String>
pub fn split_sheet(&self, source: &SheetSource) -> Result<SplitSheet, String>
Write a sheet back as a board’s schematic and a wiring diagram, each one EQUAL
to the one SheetSource merged where nothing of it was edited.
- The schematic holds the parts on the board, the nets and the layout; it is
Nonewhen there was none and the sheet has nothing of the board’s. - The diagram holds the parts off the board, the harness wires, and a twin of each part on the board that a harness wire reaches (or that had one).
Source§impl Document
impl Document
Sourcepub fn new(kind: DocumentKind) -> Self
pub fn new(kind: DocumentKind) -> Self
An empty document of the given kind.
Sourcepub fn place_unbound(&mut self, symbol: Symbol, at: Point, rotation: u8) -> Uuid
pub fn place_unbound(&mut self, symbol: Symbol, at: Point, rotation: u8) -> Uuid
Put a symbol on the sheet with NO part and NO assembly occurrence behind it.
A BREP sheet is one view of an assembly: every valued component on it is an
assembly component, and the one way to put one down is
Document::place_assembly_component, after the part has been added to the
assembly. This primitive is left public for the two things that are NOT
assembly components — a power symbol, which names a net
(Document::place_power_symbol), and an editor’s preview sheet — and for
tests that build a sheet shape directly. No editor door reaches it for a
valued part: a saved component with a part and no occurrence is the LEGACY
shape, which the host binds to an assembly component on open.
Sourcepub fn place_power_symbol(
&mut self,
symbol: Symbol,
at: Point,
rotation: u8,
) -> Result<Uuid, String>
pub fn place_power_symbol( &mut self, symbol: Symbol, at: Point, rotation: u8, ) -> Result<Uuid, String>
Put a power symbol on the sheet: a #PWR symbol that names a net
(Symbol::power_net) and is no part — it has no footprint, no BOM line
and no assembly occurrence. Refused for any other symbol: a valued part
goes on a sheet through Document::place_assembly_component alone.
Sourcepub fn place_assembly_component(
&mut self,
occurrence: &str,
part: PartSource,
symbol: Symbol,
pads: Option<Footprint>,
reference: Option<String>,
at: Point,
rotation: u8,
) -> Result<Uuid, String>
pub fn place_assembly_component( &mut self, occurrence: &str, part: PartSource, symbol: Symbol, pads: Option<Footprint>, reference: Option<String>, at: Point, rotation: u8, ) -> Result<Uuid, String>
Place an ASSEMBLY COMPONENT on the sheet. occurrence is the assembly
occurrence the component IS (ACOMP3, or ACOMP7:ACOMP1 for a device
inside a sub-assembly): the symbol and pads of its part are copied into
the document, and the component records the occurrence with the part’s
key and version (part.key, part.signature; part.instance is
overwritten with occurrence). reference is the label the host gives
it — its reference designator — or the next free one when it has none.
This is the ONE way a valued component reaches a sheet. It takes the occurrence as a required argument so that a sheet component without an assembly component behind it cannot be written: a board is an assembly, and its footprints are the assembly’s components seen from above. An occurrence already on the sheet is refused — one component per occurrence.
Sourcepub fn set_reference(&mut self, id: Uuid, reference: &str) -> Result<(), String>
pub fn set_reference(&mut self, id: Uuid, reference: &str) -> Result<(), String>
Give a placed part the label a host keeps for it, such as its reference designator. Labels are nonempty and unique in the document.
Sourcepub fn set_value(&mut self, ids: &[Uuid], value: &str) -> usize
pub fn set_value(&mut self, ids: &[Uuid], value: &str) -> usize
Give each of ids the value value (10k), as one edit: the value the
sheet draws under the reference, and the one the BOM groups by and the
netlist and pick-and-place write. Taken as given, as the Inspector’s field
types it (trimming there would eat the space of 10 k as it is typed); an
empty value is allowed, as KiCad allows it. Returns how many changed.
Sourcepub fn unvalued_siblings(&self, id: Uuid) -> Vec<Uuid>
pub fn unvalued_siblings(&self, id: Uuid) -> Vec<Uuid>
The components that still carry the value their symbol gave them when
they were placed (Symbol::default_value) and are placed from the same
symbol as id, other than id itself, in reference order: the parts a
value typed for id is offered to as well.
Sourcepub fn parts(&self) -> Vec<PartSource>
pub fn parts(&self) -> Vec<PartSource>
Every part the document has components from, with the version each was copied from. A host compares these against its own parts to find what to refresh.
Sourcepub fn refresh_part(
&mut self,
key: &str,
symbol: &Symbol,
pads: Option<&Footprint>,
signature: &str,
renames: &BTreeMap<String, String>,
) -> Result<usize, String>
pub fn refresh_part( &mut self, key: &str, symbol: &Symbol, pads: Option<&Footprint>, signature: &str, renames: &BTreeMap<String, String>, ) -> Result<usize, String>
Take a new version of one part into every component placed from it: its symbol
and pads are copied again, and each component records signature. renames
maps a pin label of the old version to its label in the new one; connections on
a renamed pin move to its new label, connections on the pins whose labels remain
stay, and the rest go. Returns how many components were refreshed. A refusal
leaves the document as it was.
Sourcepub fn refresh_component(
&mut self,
component: Uuid,
symbol: &Symbol,
pads: Option<&Footprint>,
signature: &str,
renames: &BTreeMap<String, String>,
) -> Result<(), String>
pub fn refresh_component( &mut self, component: Uuid, symbol: &Symbol, pads: Option<&Footprint>, signature: &str, renames: &BTreeMap<String, String>, ) -> Result<(), String>
Take a new version of a part into ONE placed component — the
per-component half of Document::refresh_part, for a host that
decides component by component which version each carries.
A host whose parts nest cannot name one key and mean them all: the same
key spells a different part at every level of an assembly tree, and one
occurrence’s version lives in its OWN parent’s library. Such a host
resolves each component’s device itself and hands the result here.
renames and the atomicity are Document::refresh_part’s; only the
PartSource’s signature is re-stamped, so a component keeps the key
it was placed from — Document::relink is the call that moves that.
Sourcepub fn relink(
&mut self,
component: Uuid,
part: PartSource,
symbol: &Symbol,
pads: Option<&Footprint>,
renames: &BTreeMap<String, String>,
) -> Result<(), String>
pub fn relink( &mut self, component: Uuid, part: PartSource, symbol: &Symbol, pads: Option<&Footprint>, renames: &BTreeMap<String, String>, ) -> Result<(), String>
Bind a placed component to a DIFFERENT device — the resolving half of the UNLINKED lane.
A sheet component names its device by OCCURRENCE (PartSource::instance),
and neither half of that is stable on its own: an occurrence chain
changes whenever the device is moved in the assembly tree, and the
parts-library key is not stable across a part’s version history. When
the binding cannot be resolved the component goes UNLINKED and the USER
picks its device; this is what that pick does. Nothing is guessed at
here, and nothing but the binding moves: the component keeps where it
sits, what it is called, and every wire landing on a pin it still has.
A device already placed on this sheet is refused, as
Document::place_assembly_component refuses one.
pub fn add_wire(&mut self, a: Point, b: Point)
Sourcepub fn set_net_flag(
&mut self,
terminal: Terminal,
name: &str,
) -> Result<Uuid, String>
pub fn set_net_flag( &mut self, terminal: Terminal, name: &str, ) -> Result<Uuid, String>
Create or rename the flag attached to this pin. Equal names share a net.
Sourcepub fn transform_label(&mut self, id: Uuid, at: Point, rotation: u8)
pub fn transform_label(&mut self, id: Uuid, at: Point, rotation: u8)
Move the tip; free wire endpoints follow, and direct pin contact is recomputed at the new location.
pub fn terminal_position(&self, terminal: &Terminal) -> Option<Point>
Sourcepub fn net_terminal_at(&self, at: Point) -> Option<Terminal>
pub fn net_terminal_at(&self, at: Point) -> Option<Terminal>
Document::terminal_at, for a net: never a pin of a sheet’s part off the board.
pub fn terminal_at(&self, at: Point) -> Option<Terminal>
Sourcepub fn connection_path(
&self,
start: &Terminal,
end: &Terminal,
) -> Option<Vec<Point>>
pub fn connection_path( &self, start: &Terminal, end: &Terminal, ) -> Option<Vec<Point>>
Short orthogonal route with outward terminal leads. Avoid crossing other terminal positions; this is deliberately not a full obstacle router.
pub fn target_position(&self, target: &ConnectionTarget) -> Option<Point>
pub fn target_path( &self, start: &ConnectionTarget, end: &ConnectionTarget, ) -> Option<Vec<Point>>
pub fn connect_targets( &mut self, start: ConnectionTarget, end: ConnectionTarget, ) -> Option<Uuid>
Sourcepub fn connect_targets_as(
&mut self,
start: ConnectionTarget,
end: ConnectionTarget,
harness: bool,
) -> Option<Uuid>
pub fn connect_targets_as( &mut self, start: ConnectionTarget, end: ConnectionTarget, harness: bool, ) -> Option<Uuid>
Document::connect_targets drawing a harness wire (harness) or a net.
Only a DocumentKind::Sheet holds both; the other kinds draw their own.
pub fn connect(&mut self, start: Terminal, end: Terminal) -> Option<Uuid>
Sourcepub fn connect_as(
&mut self,
start: Terminal,
end: Terminal,
harness: bool,
) -> Option<Uuid>
pub fn connect_as( &mut self, start: Terminal, end: Terminal, harness: bool, ) -> Option<Uuid>
Document::connect drawing a harness wire (harness) or a net. A schematic
draws only nets and a wiring diagram only harness wires, whatever is asked.
Sourcepub fn attached_harness_wire(&self, terminal: &Terminal) -> Option<&Wire>
pub fn attached_harness_wire(&self, terminal: &Terminal) -> Option<&Wire>
The HARNESS wire with an end attached to this pin, if any: the connection a harness pin takes one of. A net on the same pin is not one.
Sourcepub fn attached_wire(&self, terminal: &Terminal) -> Option<&Wire>
pub fn attached_wire(&self, terminal: &Terminal) -> Option<&Wire>
The wire with an end attached to this pin, if any.
Sourcepub fn terminal_name(&self, terminal: &Terminal) -> String
pub fn terminal_name(&self, terminal: &Terminal) -> String
A pin as reference and pin number, such as R1.2.
Sourcepub fn connections(&self) -> Vec<Connection>
pub fn connections(&self) -> Vec<Connection>
A wiring diagram’s point-to-point connections, ordered by connection ID. Each runs from the pin its wire was drawn from; a port is a pin number.
Sourcepub fn connections_csv(&self) -> Result<String, String>
pub fn connections_csv(&self) -> Result<String, String>
The connection list as CSV: a header row, then one row per connection.
Sourcepub fn migrate_legacy_units(&mut self) -> Vec<String>
pub fn migrate_legacy_units(&mut self) -> Vec<String>
Bring every component whose symbol the KiCad import wrote before gates
existed up to the gate shape (Symbol::migrate_legacy_units), each
gate placed exactly where the symbol drawn whole put it, so no pin, wire
or flag moves. Returns the references of the components it changed.
A host calls this where it OPENS a stored sheet, and adopts the result as part of the document rather than as an edit: nothing the user drew changes, and a sheet not saved again is migrated the same way the next time it is opened.
Sourcepub fn replace_component_symbol(
&mut self,
id: Uuid,
symbol: Symbol,
) -> Result<(), String>
pub fn replace_component_symbol( &mut self, id: Uuid, symbol: Symbol, ) -> Result<(), String>
Replace one instance’s definition, retaining connectivity by pin number.
Sourcepub fn transform_component(&mut self, id: Uuid, at: Point, rotation: u8)
pub fn transform_component(&mut self, id: Uuid, at: Point, rotation: u8)
Infer attachments on legacy/free wires before moving, then keep them attached.
A component whose gates are placed apart moves as one: every gate goes
with it, turned about at by the same quarter turns.
Sourcepub fn transform_gate(&mut self, id: Uuid, gate: u32, at: Point, rotation: u8)
pub fn transform_gate(&mut self, id: Uuid, gate: u32, at: Point, rotation: u8)
Move and turn ONE gate of a component whose gates are placed apart
(Component::gates); its wires and flags follow as they follow a
component. Nothing happens for a gate the component does not place.
Sourcepub fn open_spot(&self, symbol: &Symbol) -> Point
pub fn open_spot(&self, symbol: &Symbol) -> Point
Where a new component drawn with symbol can go without covering one already
on the sheet: the first free cell, row by row and eight to a row, of a grid
that starts at the sheet origin. A cell is the symbol’s own box plus a gap:
10.16 mm across, which is room for the reference and value an editor writes
to the right of a symbol (two lines of text, some 80 points wide at the
default zoom), and 5.08 mm down. The origin itself when it is free, so the
first part lands where it always did.
A host that seats parts on its own, with no pointer to say where, asks this rather than stacking every part at the origin: stacked parts publish the same rect, and a click or a drag reaches only the one drawn last (the eCAD workflow audit, issue 6).
Sourcepub fn covers_another(&self, id: Uuid) -> bool
pub fn covers_another(&self, id: Uuid) -> bool
Whether component id covers part of another component, each taken as the box
its symbol spans grown by half a sheet grid step (635 µm) on every side — so a
symbol that is only a row of pins, whose box has no height, still covers one
drawn on top of it, and parts a whole grid step apart do not.
pub fn delete_component(&mut self, id: Uuid)
pub fn from_json(text: &str) -> Result<Self, String>
pub fn to_json(&self) -> Result<String, String>
Sourcepub fn from_value(value: Value) -> Result<Self, String>
pub fn from_value(value: Value) -> Result<Self, String>
Read a document kept inside a host’s own JSON file, with the same migration and
checks as Document::from_json.
Sourcepub fn to_value(&self) -> Result<Value, String>
pub fn to_value(&self) -> Result<Value, String>
The document as a JSON value for a host’s own file, checked as
Document::to_json checks it.