aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin/post_file_download_event.rs
blob: 9ba946ed483c909786c5c8cbc07e71f4cdbabfc2 (plain)
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
//! ref: composer/src/Composer/Plugin/PostFileDownloadEvent.php

use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;

use crate::event_dispatcher::Event;
use crate::event_dispatcher::EventInterface;

#[derive(Debug)]
pub struct PostFileDownloadEvent {
    inner: Event,
    file_name: Option<String>,
    checksum: Option<String>,
    url: String,
    context: PhpMixed,
    r#type: String,
}

impl PostFileDownloadEvent {
    pub fn new(
        name: String,
        file_name: Option<String>,
        checksum: Option<String>,
        url: String,
        r#type: String,
        context: PhpMixed,
    ) -> Self {
        Self {
            inner: Event::new(name, vec![], indexmap::IndexMap::new()),
            file_name,
            checksum,
            url,
            context,
            r#type,
        }
    }

    pub fn get_name(&self) -> &str {
        self.inner.get_name()
    }

    pub fn get_file_name(&self) -> Option<&str> {
        self.file_name.as_deref()
    }

    pub fn get_checksum(&self) -> Option<&str> {
        self.checksum.as_deref()
    }

    pub fn get_url(&self) -> &str {
        &self.url
    }

    pub fn get_context(&self) -> &PhpMixed {
        &self.context
    }

    pub fn get_type(&self) -> &str {
        &self.r#type
    }
}

impl EventInterface for PostFileDownloadEvent {
    fn get_name(&self) -> &str {
        self.inner.get_name()
    }

    fn get_arguments(&self) -> &Vec<String> {
        self.inner.get_arguments()
    }

    fn get_flags(&self) -> &IndexMap<String, PhpMixed> {
        self.inner.get_flags()
    }

    fn is_propagation_stopped(&self) -> bool {
        self.inner.is_propagation_stopped()
    }

    fn stop_propagation(&mut self) {
        self.inner.stop_propagation();
    }
}