pub struct Cell {
    node_id: NodeId,
    x: u8,
    y: u8,
    out1: Option<u8>,
    out2: Option<u8>,
    out3: Option<u8>,
    in1: Option<u8>,
    in2: Option<u8>,
    in3: Option<u8>,
}
Expand description

This is a cell/tile of the hexagonal Matrix.

The Matrix stores it to keep track of the graphical representation of the hexagonal tilemap. Using Matrix::place you can place new cells.

 use hexodsp::*;

 let (node_conf, mut node_exec) = new_node_engine();
 let mut matrix = Matrix::new(node_conf, 3, 3);

 matrix.place(
     2, 2,
     Cell::empty(NodeId::Sin(0))
     .input(Some(0), None, None)
     .out(None, None, Some(0)));

 matrix.sync().unwrap();

Fields

node_id: NodeIdx: u8y: u8out1: Option<u8>

Top-Right output

out2: Option<u8>

Bottom-Right output

out3: Option<u8>

Bottom output

in1: Option<u8>

Top input

in2: Option<u8>

Top-Left input

in3: Option<u8>

Bottom-Left input

Implementations

This is the main contructor of a Cell. Empty means that there is no associated position of this cell and no inputs/outputs have been assigned. Use the methods Cell::input and Cell::out to assign inputs / outputs.

 use hexodsp::*;

 let some_cell =
     Cell::empty(NodeId::Sin(0))
     .input(None, Some(0), Some(0))
     .out(None, Some(0), Some(0));

This is an alternative constructor, in case you know the position of the cell before you got it from the Matrix.

Returns a serializable representation of this Matrix Cell.

See also CellRepr.

 use hexodsp::*;

 let some_cell =
     Cell::empty(NodeId::Sin(0))
     .input(None, Some(0), Some(0))
     .out(None, Some(0), Some(0));

 let repr = some_cell.to_repr();
 assert_eq!(
     repr.serialize().to_string(),
     "[\"sin\",0,0,0,[-1,\"freq\",\"freq\"],[-1,\"sig\",\"sig\"]]");

This is a helper function to quickly set an input by name and direction.

 use hexodsp::*;

 let mut cell = Cell::empty(NodeId::Sin(0));
 cell.set_input_by_name("freq", CellDir::T).unwrap();

This is a helper function to quickly set an output by name and direction.

 use hexodsp::*;

 let mut cell = Cell::empty(NodeId::Sin(0));
 cell.set_output_by_name("sig", CellDir::B).unwrap();

Finds the first free input or output (one without an adjacent cell). If any free input/output has an assigned input, that edge is returned before any else. With dir you can specify input with CellDir::T, output with CellDir::B and any with CellDir::C.

Finds the all adjacent free places around the current cell. With dir you can specify input with CellDir::T, output with CellDir::B and any with CellDir::C.

Finds all dangling ports in the specified direction. With dir you can specify input with CellDir::T, output with CellDir::B and any with CellDir::C.

If the port is connected, it will return the position of the other cell.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.