df_st_core/df_world/
river.rs

1use crate::create_new::CreateNew;
2use crate::fillable::{Fillable, Filler};
3use crate::positions::{Coordinate, Path};
4use crate::SchemaExample;
5use df_st_derive::{Fillable, Filler, HashAndPartialEqById};
6use juniper::GraphQLObject;
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9
10/// An River is a stream of water in the world.
11#[derive(
12    Serialize,
13    Deserialize,
14    Clone,
15    Debug,
16    HashAndPartialEqById,
17    Fillable,
18    Filler,
19    Default,
20    JsonSchema,
21    GraphQLObject,
22)]
23pub struct River {
24    /// Identifier for the river.
25    /// `id` must be unique for the whole world.
26    /// This value is not given from files but generated after parsing.
27    pub id: i32,
28    /// The name of the river
29    pub name: Option<String>,
30    /// The path the stream takes
31    /// TODO path is upstream of downstream?
32    pub path: Vec<Path>,
33    /// The coordinates of the point where the river ends.
34    /// This is usually where it meets the see or ocean or another river.
35    pub end_pos: Option<Coordinate>,
36}
37
38impl CreateNew for River {
39    fn new_by_id(id: i32) -> Self {
40        Self {
41            id,
42            ..Default::default()
43        }
44    }
45}
46
47impl SchemaExample for River {
48    fn example() -> Self {
49        Self::default()
50    }
51}