rustsynth/lib.rs
1//! A safe wraper for [VapourSynth], written in Rust
2//!
3//! Is a fork of [vapoursynth-rs] project for the latest VapourSynth API version
4//!
5//! The primary goal is safety (that is, safe Rust code should not trigger undefined behavior), and secondary goals include performance and ease of use.
6//!
7//! [VapourSynth]: https://github.com/vapoursynth/vapoursynth
8//! [vapoursynth-rs]: https://github.com/YaLTeR/vapoursynth-rs
9
10pub extern crate rustsynth_sys;
11pub use rustsynth_sys as ffi;
12
13mod api;
14pub mod core;
15pub mod filter;
16pub mod format;
17pub mod frame;
18pub mod function;
19pub mod log;
20pub mod map;
21pub mod node;
22pub mod plugin;
23#[cfg(feature = "vsscript-functions")]
24pub mod vsscript;
25pub use api::init_api;
26
27pub mod prelude {
28 //! The VapourSynth prelude.
29 //!
30 //! Contains the types you most likely want to import anyway.
31 pub use super::map::Map;
32
33 #[cfg(feature = "vsscript-functions")]
34 pub use super::vsscript::Environment;
35}
36
37pub fn api_version() -> i32 {
38 api::API::get().unwrap().version()
39}
40
41/// A simple macro to create an owned map
42///
43/// its syntax is `owned_map!({"key": value}, ... , {"key": value})`
44///
45/// # Example
46///
47/// ```
48/// use rustsynth::owned_map;
49/// let map = owned_map!({"int": &0});
50/// ```
51#[macro_export(local_inner_macros)]
52macro_rules! owned_map {
53 ($({$key:literal: $x:expr }),*) => {
54 {
55 let mut temp_map = $crate::map::OwnedMap::new();
56 $(
57 temp_map.set($key, $x).unwrap();
58 )*
59 temp_map
60 }
61 };
62}
63
64/// A trait to provide a method to consume a struct and output an `map::OwnedMap`
65pub trait OwnedMap {
66 fn to_map<'elem>(self) -> map::OwnedMap<'elem>;
67}
68
69// Dev notes
70//
71// There is one API so if something is created or executed through the API then can get it once then use cached version everytime afterwards
72// so things that are at the front: Core, Ownedmaps
73//
74
75pub use ffi::version as MakeVersion;