[][src]Struct kaze::Context

#[must_use]pub struct Context<'a> { /* fields omitted */ }

A top-level container/owner object for a Module graph.

A Context owns all parts of a module graph, and provides an API for creating Module objects.

Examples

use kaze::*;

let c = Context::new();

let m = c.module("MyModule");
m.output("out", m.input("in", 1));

Methods

impl<'a> Context<'a>[src]

pub fn new() -> Context<'a>[src]

Creates a new, empty Context.

Examples

use kaze::*;

let c = Context::new();

pub fn module<S: Into<String>>(&'a self, name: S) -> &Module[src]

Creates a new Module called name in this Context.

Conventionally, name should be CamelCase, though this is not enforced.

Panics

Panics if a Module with the same name already exists in this Context.

Examples

use kaze::*;

let c = Context::new();

let my_module = c.module("MyModule");
let another_mod = c.module("AnotherMod");

The following example panics by creating a Module with the same name as a previously-created Module in the same Context:

use kaze::*;

let c = Context::new();

let _ = c.module("A"); // Unique name, OK
let _ = c.module("B"); // Unique name, OK

let _ = c.module("A"); // Non-unique name, panic!

pub fn modules(&'a self) -> Ref<BTreeMap<String, &'a Module<'a>>>[src]

Immutably borrows this Context's Modules.

This is primarily useful for iterating over every Module in this Context when generating code.

Examples

use kaze::*;

let c = Context::new();

let my_module = c.module("MyModule");
let another_mod = c.module("AnotherMod");

assert_eq!(c.modules().len(), 2);

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Context<'a>

impl<'a> !Send for Context<'a>

impl<'a> !Sync for Context<'a>

impl<'a> Unpin for Context<'a>

impl<'a> !UnwindSafe for Context<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.