ConstructCraft Docs Download free

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

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

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

struct Converted

pub struct Converted

A Revit file written as IFC4.

Traits: Debug, Clone

Fields

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

Methods

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.