Skip to main content

Flow

Trait Flow 

Source
pub trait Flow {
    type WithoutGenerics: Flow + ?Sized;
    type OptionInnerType: ?Sized;

    const IS_ENUM: bool = false;
Show 14 methods // Required methods fn name(cfg: &Config) -> String; fn inline(cfg: &Config) -> String; // Provided methods fn docs() -> Option<String> { ... } fn ident(cfg: &Config) -> String { ... } fn decl(cfg: &Config) -> String { ... } fn decl_concrete(cfg: &Config) -> String { ... } fn inline_flattened(cfg: &Config) -> String { ... } fn visit_dependencies(_: &mut impl TypeVisitor) where Self: 'static { ... } fn visit_generics(_: &mut impl TypeVisitor) where Self: 'static { ... } fn dependencies(cfg: &Config) -> Vec<Dependency> where Self: 'static { ... } fn output_path() -> Option<PathBuf> { ... } fn export(cfg: &Config) -> Result<(), ExportError> where Self: 'static { ... } fn export_all(cfg: &Config) -> Result<(), ExportError> where Self: 'static { ... } fn export_to_string(cfg: &Config) -> Result<String, ExportError> where Self: 'static { ... }
}
Expand description

The core trait. Derive it on your types to generate Flow declarations.

Mirrors the ts-rs TS trait interface.

Provided Associated Constants§

Source

const IS_ENUM: bool = false

Whether this is an enum type.

Required Associated Types§

Source

type WithoutGenerics: Flow + ?Sized

If this type does not have generic parameters, then WithoutGenerics should be Self. If the type does have generic parameters, then all generic parameters must be replaced with a dummy type, e.g flowjs_rs::Dummy or (). The only requirement for these dummy types is that output_path() must return None.

Source

type OptionInnerType: ?Sized

If the implementing type is std::option::Option<T>, then this associated type is set to T. All other implementations of Flow should set this type to Self instead.

Required Methods§

Source

fn name(cfg: &Config) -> String

Flow type name, including generic parameters.

Source

fn inline(cfg: &Config) -> String

Inline Flow type definition (the right-hand side of type X = ...).

Provided Methods§

Source

fn docs() -> Option<String>

JSDoc/Flow comment to describe this type – when Flow is derived, docs are automatically read from your doc comments or #[doc = ".."] attributes.

Source

fn ident(cfg: &Config) -> String

Identifier of this type, excluding generic parameters.

Source

fn decl(cfg: &Config) -> String

Declaration of this type, e.g. type User = {| +user_id: number |};. This function will panic if the type has no declaration.

If this type is generic, then all provided generic parameters will be swapped for placeholders, resulting in a generic Flow definition.

Source

fn decl_concrete(cfg: &Config) -> String

Declaration of this type using the supplied generic arguments. The resulting Flow definition will not be generic. For that, see Flow::decl(). If this type is not generic, then this function is equivalent to Flow::decl().

Source

fn inline_flattened(cfg: &Config) -> String

Flatten a type declaration. This function will panic if the type cannot be flattened.

Source

fn visit_dependencies(_: &mut impl TypeVisitor)
where Self: 'static,

Iterate over all dependencies of this type.

Source

fn visit_generics(_: &mut impl TypeVisitor)
where Self: 'static,

Iterate over all type parameters of this type.

Source

fn dependencies(cfg: &Config) -> Vec<Dependency>
where Self: 'static,

Resolve all dependencies of this type recursively.

Source

fn output_path() -> Option<PathBuf>

Output file path relative to the export directory.

Source

fn export(cfg: &Config) -> Result<(), ExportError>
where Self: 'static,

Export this type to disk.

Source

fn export_all(cfg: &Config) -> Result<(), ExportError>
where Self: 'static,

Export this type to disk, together with all of its dependencies.

Source

fn export_to_string(cfg: &Config) -> Result<String, ExportError>
where Self: 'static,

Render this type as a string, returning the full file content.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Flow for IpAddr

Source§

impl Flow for SocketAddr

Source§

impl Flow for bool

Source§

impl Flow for char

Source§

impl Flow for f32

Source§

impl Flow for f64

Source§

impl Flow for i8

Source§

impl Flow for i16

Source§

impl Flow for i32

Source§

impl Flow for i64

Source§

impl Flow for i128

Source§

impl Flow for isize

Source§

impl Flow for str

Source§

impl Flow for u8

Source§

impl Flow for u16

Source§

impl Flow for u32

Source§

impl Flow for u64

Source§

impl Flow for u128

Source§

impl Flow for ()

Source§

impl Flow for usize

Source§

impl Flow for String

Source§

impl Flow for Ipv4Addr

Source§

impl Flow for Ipv6Addr

Source§

impl Flow for SocketAddrV4

Source§

impl Flow for SocketAddrV6

Source§

impl Flow for Duration

Source§

impl Flow for Path

Source§

impl Flow for PathBuf

Source§

impl Flow for SystemTime

Source§

impl Flow for NonZeroI8

Source§

impl Flow for NonZeroI16

Source§

impl Flow for NonZeroI32

Source§

impl Flow for NonZeroI64

Source§

impl Flow for NonZeroI128

Source§

impl Flow for NonZeroIsize

Source§

impl Flow for NonZeroU8

Source§

impl Flow for NonZeroU16

Source§

impl Flow for NonZeroU32

Source§

impl Flow for NonZeroU64

Source§

impl Flow for NonZeroU128

Source§

impl Flow for NonZeroUsize

Source§

impl<'a, T: Flow + ToOwned + ?Sized> Flow for Cow<'a, T>

Source§

type WithoutGenerics = Cow<'a, T>

Source§

type OptionInnerType = Cow<'a, T>

Source§

fn name(cfg: &Config) -> String

Source§

fn inline(cfg: &Config) -> String

Source§

fn inline_flattened(cfg: &Config) -> String

Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn decl(_: &Config) -> String

Source§

fn decl_concrete(_: &Config) -> String

Source§

impl<'a, T: Flow + ?Sized> Flow for &'a T

Source§

impl<A: Flow, B: Flow, C: Flow, D: Flow, E: Flow, F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<B: Flow, C: Flow, D: Flow, E: Flow, F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<C: Flow, D: Flow, E: Flow, F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (C, D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<D: Flow, E: Flow, F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (D, E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<E: Flow, F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (E, F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<F: Flow, G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (F, G, H, I, J, K, L, M, N, O, P)

Source§

impl<G: Flow, H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (G, H, I, J, K, L, M, N, O, P)

Source§

impl<H: Flow, I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (H, I, J, K, L, M, N, O, P)

Source§

impl<I: Flow, J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (I, J, K, L, M, N, O, P)

Source§

impl<J: Flow, K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (J, K, L, M, N, O, P)

Source§

impl<K: Flow, L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (K, L, M, N, O, P)

Source§

impl<K: Flow, V: Flow> Flow for BTreeMap<K, V>

Source§

impl<K: Flow, V: Flow> Flow for HashMap<K, V>

Source§

impl<L: Flow, M: Flow, N: Flow, O: Flow, P: Flow> Flow for (L, M, N, O, P)

Source§

impl<M: Flow, N: Flow, O: Flow, P: Flow> Flow for (M, N, O, P)

Source§

impl<N: Flow, O: Flow, P: Flow> Flow for (N, O, P)

Source§

impl<O: Flow, P: Flow> Flow for (O, P)

Source§

impl<P: Flow> Flow for (P,)

Source§

impl<T: Flow + ?Sized> Flow for Box<T>

Source§

impl<T: Flow + ?Sized> Flow for Rc<T>

Source§

impl<T: Flow + ?Sized> Flow for Arc<T>

Source§

impl<T: Flow> Flow for Option<T>

Source§

type WithoutGenerics = Option<T>

Source§

type OptionInnerType = T

Source§

fn name(cfg: &Config) -> String

Source§

fn inline(cfg: &Config) -> String

Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

impl<T: Flow> Flow for [T]

Source§

impl<T: Flow> Flow for BTreeSet<T>

Source§

impl<T: Flow> Flow for LinkedList<T>

Source§

impl<T: Flow> Flow for VecDeque<T>

Source§

impl<T: Flow> Flow for Vec<T>

Source§

type WithoutGenerics = Vec<Dummy>

Source§

type OptionInnerType = Vec<T>

Source§

fn ident(_: &Config) -> String

Source§

fn name(cfg: &Config) -> String

Source§

fn inline(cfg: &Config) -> String

Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

impl<T: Flow> Flow for Cell<T>

Source§

impl<T: Flow> Flow for RefCell<T>

Source§

impl<T: Flow> Flow for Range<T>

Source§

impl<T: Flow> Flow for RangeInclusive<T>

Source§

impl<T: Flow> Flow for HashSet<T>

Source§

impl<T: Flow> Flow for Mutex<T>

Source§

impl<T: Flow> Flow for RwLock<T>

Source§

impl<T: Flow, E: Flow> Flow for Result<T, E>

Source§

type WithoutGenerics = Result<Dummy, Dummy>

Source§

type OptionInnerType = Result<T, E>

Source§

fn name(cfg: &Config) -> String

Source§

fn inline(cfg: &Config) -> String

Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

impl<T: Flow, const N: usize> Flow for [T; N]

Source§

type WithoutGenerics = [Dummy; N]

Source§

type OptionInnerType = [T; N]

Source§

fn name(cfg: &Config) -> String

Source§

fn inline(cfg: &Config) -> String

Source§

fn visit_dependencies(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

fn visit_generics(v: &mut impl TypeVisitor)
where Self: 'static,

Source§

impl<T: ?Sized> Flow for PhantomData<T>

Implementors§