Struct snowcap::netsim::config::Config[][src]

pub struct Config { /* fields omitted */ }
Expand description

Network Configuration

This struct represents the configuration of a network. It is made up of several unordered ConfigExpr. Two configurations can be compared by computing the difference, which returns a ConfigPatch.

In comparison to the Patch, a Config struct is unordered, which means that it just represents the configuration, but not the way how it got there.

The Config struct contains only “unique” ConfigExpr. This means, that a config cannot have a expression to set a specific link weight to 1, and another expression setting the same link to 2.0.


Create an empty configuration

Add a single configuration expression. This fails if a similar expression already exists.

Apply a single ConfigModifier to the configuration, updating the Config struct. This function checks if the modifier can be applied. If the modifier inserts an already existing expression, or if the modifier removes or updates a non-existing expression, the function will return an error, and the Config struct will remain untouched.

For Modifiers of type ConfigModifier::Update, the first from expression does not exactly need to match the existing config expression. It just needs to have the same ConfigExprKey as the already existing expression. Also, both expressions in ConfigModifier::Update must produce the same ConfigExprKey.

Apply a patch on the current configuration. self will be updated to reflect all chages in the patch. The function will return an error if the patch cannot be applied. If an error occurs, the config will remain untouched.

returns a ConfigPatch containing the difference between self and other When the patch is applied on self, it will be the same as other.

Returns the number of config expressions in the config.

Returns true if the config is empty

Returns an iterator over all expressions in the configuration.

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

Returns the “default value” for a type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.