summaryrefslogtreecommitdiff
path: root/meap/ch4/src/main.rs
blob: fd00fef683fd30915d4925dce08715ff63697832 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//#[derive(Debug, Clone, Copy)]
//struct CubeSat {
//    id: u64,
//}
//
//impl CubeSat {
//    fn recv(&self, mailbox: &mut Mailbox) -> Option<Message> {
//        mailbox.deliver(&self)
//    }
//}
//
////impl Copy for CubeSat {}
////
////impl Clone for CubeSat {
////    fn clone(&self) -> Self {
////        CubeSat {
////            id: self.id,
////        }
////    }
////}
//
//#[derive(Debug, Clone, Copy)]
//enum StatusMessage {
//    Ok,
//}
//
////impl Copy for StatusMessage {}
////
////impl Clone for StatusMessage {
////    fn clone(&self) -> Self {
////        *self
////    }
////}
//
//#[derive(Debug)]
//struct Mailbox {
//    messages: Vec<Message>,
//}
//
//impl Mailbox {
//    fn post(&mut self, msg: Message) {
//        self.messages.push(msg);
//    }
//
//    fn deliver(&mut self, recipient: &CubeSat) -> Option<Message> {
//        for i in 0..self.messages.len() {
//            if self.messages[i].to == recipient.id {
//                let msg = self.messages.remove(i);
//                return Some(msg);
//            }
//        }
//
//        None
//    }
//}
//
//struct GroundStation {}
//
//impl GroundStation {
//    fn send(&self, mailbox: &mut Mailbox, msg: Message) { 
//        mailbox.post(msg);
//    }
//
//    fn connect(&self, sat_id: u64) -> CubeSat {
//        CubeSat {
//            id: sat_id,
//        }
//    }
//}
//
//#[derive(Debug)]
//struct Message {
//    to: u64,
//    content: String,
//}
//
//fn check_status(sat_id: CubeSat) -> StatusMessage {
//    StatusMessage::Ok
//}
//
//fn fetch_sat_ids() -> Vec<u64> {
//    vec![1, 2, 3]
//}
//
//fn main() {
//    let sat_a = CubeSat {
//        id: 0,
//    };
//
//    let a_status = check_status(sat_a.clone());
//    println!("a: {:?}", a_status);
//
//    let a_status = check_status(sat_a.clone());
//    println!("a: {:?}", a_status);
//}
//

use std::rc::Rc;

#[derive(Debug)]
struct GroundStation {}

fn main() {
    let base: Rc<GroundStation> = Rc::new(GroundStation {});
    dbg!(base);
}