Struct Module

Source
pub struct Module { /* private fields */ }
Expand description

A component of a Storyboard

Storyboards, in osb, are split into different components called Modules. This allows the storyboarder to have the good practice of splitting a Storyboard into different parts efficiently.

In terms of scalabitily, this allows anyone to create, share and import Modules of any kind. Everyone can publish their own Module to crates.io and anyone can use them.

This forces the storyboarder to initialize and push Modules properly onto their Storyboards. It is recommended to create a function for each new Module or create a file of its own depending on the complexity of your module.

A Module is tied to a Layer and cannot be changed.

Implementations§

Source§

impl Module

Source

pub fn new(layer: Layer) -> Self

Initializes a new Module

Examples found in repository?
examples/module.rs (line 4)
3fn module() -> Module {
4    let mut module = Module::new(Layer::Background);
5
6    let mut sprite = Sprite::new("res/sprite.png");
7    sprite.move_((0, 320, 240));
8    module.push(sprite);
9
10    module
11}
Source

pub fn push(&mut self, sprite: Sprite)

Adds a Sprite to a Module

Usage:

use osb::{Layer, Module, Sprite};
let mut module = Module::new(Layer::Background);
let mut sprite = Sprite::new("res/sprite.png");
module.push(sprite);
Examples found in repository?
examples/module.rs (line 8)
3fn module() -> Module {
4    let mut module = Module::new(Layer::Background);
5
6    let mut sprite = Sprite::new("res/sprite.png");
7    sprite.move_((0, 320, 240));
8    module.push(sprite);
9
10    module
11}
Source

pub fn output(&self) -> String

Returns the contents of the Module

Warning: this method is not meant to be used

Source

pub fn layer(&self) -> Layer

Returns the layer of the Module

Example:

use osb::{Layer, Module};
let mut module = Module::new(Layer::Background);
assert_eq!(module.layer(), Layer::Background);

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.