added 2 plugins
This commit is contained in:
		
							parent
							
								
									f55279b7ef
								
							
						
					
					
						commit
						ca71830262
					
				
							
								
								
									
										194
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										194
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -2,6 +2,21 @@
 | 
			
		|||
# It is not intended for manual editing.
 | 
			
		||||
version = 3
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "android-tzdata"
 | 
			
		||||
version = "0.1.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "android_system_properties"
 | 
			
		||||
version = "0.1.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "libc",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "anstream"
 | 
			
		||||
version = "0.6.14"
 | 
			
		||||
| 
						 | 
				
			
			@ -57,6 +72,18 @@ version = "1.0.86"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "autocfg"
 | 
			
		||||
version = "1.3.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "bumpalo"
 | 
			
		||||
version = "3.16.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "bytes"
 | 
			
		||||
version = "1.6.0"
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +96,32 @@ version = "1.1.7"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cc"
 | 
			
		||||
version = "1.0.99"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "cfg-if"
 | 
			
		||||
version = "1.0.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "chrono"
 | 
			
		||||
version = "0.4.38"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "android-tzdata",
 | 
			
		||||
 "iana-time-zone",
 | 
			
		||||
 "js-sys",
 | 
			
		||||
 "num-traits",
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
 "windows-targets",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "clap"
 | 
			
		||||
version = "4.5.7"
 | 
			
		||||
| 
						 | 
				
			
			@ -109,17 +162,42 @@ version = "0.7.1"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "clock"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "dim_sdk",
 | 
			
		||||
 "lazy_static",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "colorchoice"
 | 
			
		||||
version = "1.0.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "core-foundation-sys"
 | 
			
		||||
version = "0.8.6"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "counter"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "dim_sdk",
 | 
			
		||||
 "lazy_static",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "dim"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "camino",
 | 
			
		||||
 "chrono",
 | 
			
		||||
 "clap",
 | 
			
		||||
 "dlopen",
 | 
			
		||||
 "dlopen_derive",
 | 
			
		||||
| 
						 | 
				
			
			@ -174,12 +252,44 @@ version = "0.5.0"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "iana-time-zone"
 | 
			
		||||
version = "0.1.60"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "android_system_properties",
 | 
			
		||||
 "core-foundation-sys",
 | 
			
		||||
 "iana-time-zone-haiku",
 | 
			
		||||
 "js-sys",
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
 "windows-core",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "iana-time-zone-haiku"
 | 
			
		||||
version = "0.1.2"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cc",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "is_terminal_polyfill"
 | 
			
		||||
version = "1.70.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "js-sys"
 | 
			
		||||
version = "0.3.69"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "wasm-bindgen",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "lazy_static"
 | 
			
		||||
version = "1.4.0"
 | 
			
		||||
| 
						 | 
				
			
			@ -195,6 +305,27 @@ version = "0.2.155"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "log"
 | 
			
		||||
version = "0.4.21"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "num-traits"
 | 
			
		||||
version = "0.2.19"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "autocfg",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "once_cell"
 | 
			
		||||
version = "1.19.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "pkg-config"
 | 
			
		||||
version = "0.3.30"
 | 
			
		||||
| 
						 | 
				
			
			@ -289,6 +420,60 @@ version = "0.2.2"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen"
 | 
			
		||||
version = "0.2.92"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "cfg-if",
 | 
			
		||||
 "wasm-bindgen-macro",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-backend"
 | 
			
		||||
version = "0.2.92"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bumpalo",
 | 
			
		||||
 "log",
 | 
			
		||||
 "once_cell",
 | 
			
		||||
 "proc-macro2 1.0.85",
 | 
			
		||||
 "quote 1.0.36",
 | 
			
		||||
 "syn 2.0.66",
 | 
			
		||||
 "wasm-bindgen-shared",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-macro"
 | 
			
		||||
version = "0.2.92"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "quote 1.0.36",
 | 
			
		||||
 "wasm-bindgen-macro-support",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-macro-support"
 | 
			
		||||
version = "0.2.92"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "proc-macro2 1.0.85",
 | 
			
		||||
 "quote 1.0.36",
 | 
			
		||||
 "syn 2.0.66",
 | 
			
		||||
 "wasm-bindgen-backend",
 | 
			
		||||
 "wasm-bindgen-shared",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "wasm-bindgen-shared"
 | 
			
		||||
version = "0.2.92"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "winapi"
 | 
			
		||||
version = "0.3.9"
 | 
			
		||||
| 
						 | 
				
			
			@ -311,6 +496,15 @@ version = "0.4.0"
 | 
			
		|||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows-core"
 | 
			
		||||
version = "0.52.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "windows-targets",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "windows-sys"
 | 
			
		||||
version = "0.52.0"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
workspace = { members = [ "sdk/rust","dim_plugins/example_rust"] }
 | 
			
		||||
workspace = { members = [ "sdk/rust","dim_plugins/example_rust", "dim_plugins/clock", "dim_plugins/counter"] }
 | 
			
		||||
[package]
 | 
			
		||||
name = "dim"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
| 
						 | 
				
			
			@ -8,6 +8,7 @@ edition = "2021"
 | 
			
		|||
 | 
			
		||||
[dependencies]
 | 
			
		||||
camino = "1.1.7"
 | 
			
		||||
chrono = "0.4.38"
 | 
			
		||||
clap = { version = "4.5.7", features = ["derive"] }
 | 
			
		||||
dlopen = "0.1.8"
 | 
			
		||||
dlopen_derive = "0.1.4"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,14 @@
 | 
			
		|||
[
 | 
			
		||||
 {
 | 
			
		||||
  "directory": "/home/mcorange/@Projects/xor64/dim/dim_plugins/example_c",
 | 
			
		||||
  "directory": "/home/xomf/git-stuff/dim2/dim/dim_plugins/example_c",
 | 
			
		||||
  "arguments": [
 | 
			
		||||
   "gcc",
 | 
			
		||||
   "-c",
 | 
			
		||||
   "-o",
 | 
			
		||||
   "/home/mcorange/@Projects/xor64/dim/target/objects/example_c/main.o",
 | 
			
		||||
   "/home/xomf/git-stuff/dim2/dim/target/objects/example_c/main.o",
 | 
			
		||||
   "src/main.c",
 | 
			
		||||
   "-pie",
 | 
			
		||||
   "-I/home/mcorange/@Projects/xor64/dim/sdk/c_cxx",
 | 
			
		||||
   "-I/home/xomf/git-stuff/dim2/dim/sdk/c_cxx",
 | 
			
		||||
   "-fPIC"
 | 
			
		||||
  ],
 | 
			
		||||
  "file": "src/main.c"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								dim_plugins/clock/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								dim_plugins/clock/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
[package]
 | 
			
		||||
name = "clock"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
 | 
			
		||||
[lib]
 | 
			
		||||
crate-type=["cdylib"]
 | 
			
		||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
chrono = "0.4.38"
 | 
			
		||||
dim_sdk = {path="../../sdk/rust/"}
 | 
			
		||||
lazy_static = "1.4.0"
 | 
			
		||||
							
								
								
									
										15
									
								
								dim_plugins/clock/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								dim_plugins/clock/Makefile
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
# Must match package name in Cargo.toml
 | 
			
		||||
PLUGIN_NAME=clock
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
build: $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
 | 
			
		||||
 | 
			
		||||
$(PLUGIN_DIR)/$(PLUGIN_NAME).dim: $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so
 | 
			
		||||
	cp $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so  $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
 | 
			
		||||
 | 
			
		||||
$(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so:
 | 
			
		||||
	mkdir -p $(OBJECT_DIR)/$(PLUGIN_NAME) 
 | 
			
		||||
	cargo build --target-dir $(OBJECT_DIR)/$(PLUGIN_NAME) 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										45
									
								
								dim_plugins/clock/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								dim_plugins/clock/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
use std::fmt::Write;
 | 
			
		||||
use chrono::prelude::*;
 | 
			
		||||
use dim_sdk::{plugin_info, DimPlugin};
 | 
			
		||||
 | 
			
		||||
plugin_info!(
 | 
			
		||||
    Plug,                    // Your main global structs name that implements `DimPlugin`
 | 
			
		||||
    "Clock",                 // Plugin name
 | 
			
		||||
    "0.0.0",                 // Plugin Version (leave empty for none)
 | 
			
		||||
    "GPLv3"                  // Plugin license (leave empty for none)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
struct Plug {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Plug {
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl DimPlugin for Plug {
 | 
			
		||||
    fn init(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn poll(&mut self, f: &mut dim_sdk::CBuffer) -> dim_sdk::Result<()> {
 | 
			
		||||
        let local: DateTime<Local> = Local::now();
 | 
			
		||||
        let formatted_time = local.format("%H:%M (%Y-%m-%d)").to_string();
 | 
			
		||||
 | 
			
		||||
        write!(f, "Time: {}", formatted_time)?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
    fn pre_reload(&mut self) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    fn post_reload(&mut self) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    fn free(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										13
									
								
								dim_plugins/counter/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								dim_plugins/counter/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
[package]
 | 
			
		||||
name = "counter"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
 | 
			
		||||
[lib]
 | 
			
		||||
crate-type=["cdylib"]
 | 
			
		||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
chrono = "0.4.38"
 | 
			
		||||
dim_sdk = {path="../../sdk/rust/"}
 | 
			
		||||
lazy_static = "1.4.0"
 | 
			
		||||
							
								
								
									
										15
									
								
								dim_plugins/counter/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								dim_plugins/counter/Makefile
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
# Must match package name in Cargo.toml
 | 
			
		||||
PLUGIN_NAME=counter
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
build: $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
 | 
			
		||||
 | 
			
		||||
$(PLUGIN_DIR)/$(PLUGIN_NAME).dim: $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so
 | 
			
		||||
	cp $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so  $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
 | 
			
		||||
 | 
			
		||||
$(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so:
 | 
			
		||||
	mkdir -p $(OBJECT_DIR)/$(PLUGIN_NAME) 
 | 
			
		||||
	cargo build --target-dir $(OBJECT_DIR)/$(PLUGIN_NAME) 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										45
									
								
								dim_plugins/counter/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								dim_plugins/counter/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
use std::fmt::Write;
 | 
			
		||||
use dim_sdk::{plugin_info, DimPlugin};
 | 
			
		||||
use chrono::{NaiveDate, Local};
 | 
			
		||||
 | 
			
		||||
plugin_info!(
 | 
			
		||||
    Plug,                    // Your main global structs name that implements `DimPlugin`
 | 
			
		||||
    "counter",               // Plugin name
 | 
			
		||||
    "0.0.0",                 // Plugin Version (leave empty for none)
 | 
			
		||||
    "GPLv3"                  // Plugin license (leave empty for none)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
struct Plug {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Plug {
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl DimPlugin for Plug {
 | 
			
		||||
    fn init(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
    fn poll(&mut self, f: &mut dim_sdk::CBuffer) -> dim_sdk::Result<()> {
 | 
			
		||||
 | 
			
		||||
        let start_date = NaiveDate::from_ymd_opt(2024, 3, 8).expect("Invalid date");
 | 
			
		||||
        let current_date = Local::now().date_naive();
 | 
			
		||||
        let duration = current_date.signed_duration_since(start_date);
 | 
			
		||||
 | 
			
		||||
        write!(f, "{} days <3", duration.num_days())?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
    fn pre_reload(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
    fn post_reload(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
    fn free(&mut self) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -9,4 +9,4 @@ crate-type=["cdylib"]
 | 
			
		|||
 | 
			
		||||
[dependencies]
 | 
			
		||||
dim_sdk = {path="../../sdk/rust/"}
 | 
			
		||||
lazy_static = "1.4.0"
 | 
			
		||||
lazy_static = "1.4.0"
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user