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;
12pub extern crate rustsynth_derive;
13pub use rustsynth_derive::OwnedMap as OwnedMap;
14
15mod api;
16pub mod core;
17pub mod format;
18pub mod frame;
19pub mod function;
20pub mod map;
21pub mod node;
22pub mod plugin;
23#[cfg(feature = "vsscript-functions")]
24pub mod vsscript;
25
26pub mod prelude {
27 //! The VapourSynth prelude.
28 //!
29 //! Contains the types you most likely want to import anyway.
30 pub use super::map::Map;
31
32 #[cfg(feature = "vsscript-functions")]
33 pub use super::vsscript::Environment;
34}
35
36pub fn api_version() -> i32 {
37 api::API::get().unwrap().version()
38}
39
40/// A simple macro to create an owned map
41///
42/// its syntax is `owned_map!({"key": value}, ... , {"key": value})`
43///
44/// # Example
45///
46/// ```
47/// use rustsynth::owned_map;
48/// let map = owned_map!({"int": &0});
49/// ```
50#[macro_export(local_inner_macros)]
51macro_rules! owned_map {
52 ($({$key:literal: $x:expr }),*) => {
53 {
54 use rustsynth::map::OwnedMap;
55
56 let mut temp_map = OwnedMap::new();
57 $(
58 temp_map.set($key, $x).unwrap();
59 )*
60 temp_map
61 }
62 };
63}
64
65/// A trait for a struct that can make a `map::OwnedMap`
66pub trait OwnedMap {
67 fn to_map<'elem>(self) -> map::OwnedMap<'elem>;
68}
69
70// Dev notes
71//
72// 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
73// so things that are at the front: Core, Ownedmaps
74//