Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Attributes

Attributes are TOML like values. They can be one of the following types:

Type NameRust TypeDescription
BoolboolBoolean values (true or false)
StringRStringQuoted String Values
Integeri64Integer values (numbers)
Floatf64Float values (numbers with decimals)
DateDateDate (yyyy-mm-dd formatted)
TimeTimeTime (HH:MM, HH:MM:SS formatted)
DateTimeDateTimeDate and Time separed by or T
ArrayRVec<Attribute>List of any attribute values
Table/AttrMapAttrMapKey Value pairs of any attribute values

You can write attributes directly into the task system to assign them, use them in functions. You can also load attributes from a file into the env/node/network.

If you want to assign a attribute inside the task system, you can do it like this:

env.river = "Ohio River"
env.river

Results:

"Ohio River"

Example Attribute File that can be loaded:

river = "Ohio River"
outlet = "Smithland Lock and Dam"
outlet_is_gage = true
outlet_site_no = ""
streamflow_start = 1930-06-07
mean_streamflow = 123456.0
obs_7q10 = 19405.3
nat_7q10 = 12335.9
num_dams_gages = 2348

Here loading the files we can see only ohio has the attributes loaded

 network load_file("./data/mississippi.net")
node[ohio] load_attrs("./data/attrs/{_NAME}.toml")
node.outlet

Results:

{
  lower-mississippi = <None>,
  upper-mississippi = <None>,
  missouri = <None>,
  arkansas = <None>,
  red = <None>,
  ohio = "Smithland Lock and Dam",
  tenessee = <None>
}

With plugins, you can load attributes from different file types.