cc_rvt API
← API reference · Generated from the source by cargo run -p api_doc; edit the doc comments, not this page.
Revit project files (.rvt), read by the crates.io rvt crate (rvt-rs,
Apache-2.0, pure Rust, forbid(unsafe_code)) and written as IFC4 text,
which cc_ifc imports as it imports any IFC file.
rvt is not written to our robustness rules: a damaged file may make it
panic, overflow its stack or run without end. So the conversion runs in a
child process (convert_in_child), which is stopped after a timeout; a
crash or a stop is an error and the calling program goes on. The child is
a program that takes SUBCOMMAND and calls child_main (ccad
rvt-to-ifc and the app both do). Inside the child, the reader still runs
on its own thread with a large stack inside catch_unwind, so a panic
becomes an error in its report.
The reader’s default open and walker limits bound what it reads; a file
they keep from being read whole is refused, as rvt-ifc refuses it, since
the model would silently miss what those streams hold.
Modules
| Module | Items | Summary |
|---|---|---|
cc_rvt |
6 | Revit project files (.rvt), read by the crates.io rvt crate (rvt-rs, Apache-2.0, pure Rust, forbid(unsafe_code)) and written as IFC4 text, which cc_ifc imports as it imports any IFC file. |
cc_rvt::child |
3 | Running the converter in a child process, stopped after a timeout. |
cc_rvt
crates/cc_rvt/src/lib.rs
Re-exports
pub use child::{Converter, DEFAULT_TIMEOUT, convert_in_child}
Items: SUBCOMMAND · MAX_RVT_BYTES · RvtError · Summary · Converted · child_main
const SUBCOMMAND
pub const SUBCOMMAND: &str
The argument that makes a program run as the converter: <program>
rvt-to-ifc <file.rvt> <out.ifc> [<report.json>].
const MAX_RVT_BYTES
pub const MAX_RVT_BYTES: u64
The largest file read: the reader holds the whole file in memory.
enum RvtError
pub enum RvtError
Traits: Debug, Clone, PartialEq, Eq, Error, Serialize, Deserialize
Variants
-
Read(String)The reader refused the file: not a Revit file, damaged, or a part it cannot read.
-
Partial { streams: usize }A resource limit kept this many streams from being read whole.
-
Internal(String)The reader stopped on an internal error (a panic).
-
Timeout { seconds: u64 }The converter did not finish within this many seconds and was stopped.
-
CancelledThe caller cancelled the conversion and the converter was stopped.
-
Crashed(String)The converter ended without a report: a crash, such as a stack overflow, or a kill. The text is its last error line or exit status.
-
Process(String)The converter could not be started, or its files written or read.
struct Summary
pub struct Summary
What a conversion recovered, besides the IFC text: the report the converter writes.
Traits: Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize
Fields
-
revit_version: Option<u32>The Revit release (year) that saved the file, when read.
-
elements: usizeBuilding elements written.
-
with_geometry: usizeOf those, the elements with a body.
-
boxes: usizeBodies that are their element’s bounding box: placed and sized, shape not decoded.
-
notes: Vec<String>The converter’s notes and warnings, in order (English, from the crate).
struct Converted
pub struct Converted
A Revit file written as IFC4.
Traits: Debug, Clone
Fields
-
ifc: StringThe IFC4 file, as text.
-
summary: Summary
fn child_main
pub fn child_main(args: &[OsString]) -> u8
The converter’s side of convert_in_child: args are what follows
SUBCOMMAND, <file.rvt> <out.ifc> [<report.json>]. It writes the IFC
file and the report, a JSON {"Ok": Summary} or {"Err": RvtError}, to
<report.json> or else to standard output. Returns the exit code: 0
converted, 1 not converted, 2 wrong arguments.
cc_rvt::child
crates/cc_rvt/src/child.rs
Running the converter in a child process, stopped after a timeout.
Items: DEFAULT_TIMEOUT · Converter · convert_in_child
const DEFAULT_TIMEOUT
pub const DEFAULT_TIMEOUT: Duration
How long a conversion may take before it is stopped.
struct Converter
pub struct Converter
The program that converts, with the arguments that come before the
converter’s own (<file.rvt> <out.ifc> <report.json>).
Traits: Debug, Clone, PartialEq, Eq
Fields
program: PathBufargs: Vec<OsString>
Methods
-
pub fn this_program() -> Result<Self, RvtError>This program started again with
SUBCOMMAND, for programs that callchild_mainwhen they get it.
fn convert_in_child
pub fn convert_in_child(converter: &Converter, input: &Path, timeout: Duration, stop: &dyn Fn() -> bool) -> Result<Converted, RvtError>
Convert the Revit file input to IFC4 in a child process that runs
converter, stopped when it takes longer than timeout or when stop
returns true (checked every few milliseconds; the caller cancelled). The
IFC file and the report are written to a new folder under the system’s
temporary folder, deleted afterwards.