serde_sarif/lib.rs
1#![doc(html_root_url = "https://docs.rs/serde-sarif/0.8.0")]
2
3//! This crate provides a type safe [serde](https://serde.rs/) compatible
4//! [SARIF](https://sarifweb.azurewebsites.net/) structure. It is intended
5//! for use in Rust code which may need to read or write SARIF files.
6//!
7//! The latest [documentation can be found here](https://docs.rs/serde_sarif).
8//!
9//! serde is a popular serialization framework for Rust. More information can be
10//! found on the official repository: [https://github.com/serde-rs/serde](https://github.com/serde-rs/serde)
11//!
12//! SARIF or the Static Analysis Results Interchange Format is an industry
13//! standard format for the output of static analysis tools. More information
14//! can be found on the official website: [https://sarifweb.azurewebsites.net/](https://sarifweb.azurewebsites.net/).
15//!
16//! ## Usage
17//!
18//! For most cases, simply use the root [sarif::Sarif] struct with [serde] to read and
19//! write to and from the struct.
20//!
21//! ## Example
22//!
23//!```rust
24//! use serde_sarif::sarif::Sarif;
25//!
26//! let sarif: Sarif = serde_json::from_str(
27//! r#"{ "version": "2.1.0", "runs": [] }"#
28//! ).unwrap();
29//!
30//! assert_eq!(
31//! sarif.version.to_string(),
32//! "\"2.1.0\"".to_string()
33//! );
34//! ```
35//!
36//! Because many of the [sarif::Sarif] structures contain a lot of optional fields, it is
37//! often convenient to use the builder pattern to construct these structs. Each
38//! structure has a builder with a default.
39//!
40//! ## Example
41//!
42//! ```rust
43//! use serde_sarif::sarif::Message;
44//!
45//! let message = Message::default()
46//! .id("id")
47//! .build();
48//! ```
49//!
50//! This uses [`TypedBuilder`](typed_builder::TypedBuilder)
51//! for compile time type checking.
52//!
53//! ## Internal Implementation Details
54//!
55//! The root [sarif::Sarif] struct is automatically generated from the latest Sarif
56//! JSON schema, this is done at build time (via the buildscript).
57//!
58//! ## Crate Features
59//!
60//! This crate contains different features which may be enabled depending on your
61//! use case.
62//!
63//! ### Example
64//!
65//! ```toml
66//! [dependencies]
67//! serde-sarif = { version = "*", features = ["clippy-converters"] }
68//! ```
69//!
70//! ### Converters
71//! - **clang-tidy-converters** Provides conversions between clang tidy and SARIF types
72//! - **clippy-converters** Provides conversions between Clippy and SARIF types
73//! - **hadolint-converters** Provides conversions between hadolint and SARIF types
74//! - **shellcheck-converters** Provides conversions between shellcheck and SARIF types
75//!
76//! ### Other
77//!
78//! - **opt-builder** Enables
79//! [`TypedBuilder`](typed_builder::TypedBuilder)
80//! fallback setters for easier conditional building
81
82pub mod converters;
83pub mod sarif;