From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH 1/1] pve-rs: add PVE::RS::CalendarEvent
Date: Wed, 1 Dec 2021 09:55:13 +0100 [thread overview]
Message-ID: <20211201085514.1648428-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211201085514.1648428-1-d.csapak@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
pve-rs/Makefile | 1 +
pve-rs/src/calendar_event.rs | 20 ++++++++++++++++++++
pve-rs/src/lib.rs | 1 +
3 files changed, 22 insertions(+)
create mode 100644 pve-rs/src/calendar_event.rs
diff --git a/pve-rs/Makefile b/pve-rs/Makefile
index c912d9d..0b53d4d 100644
--- a/pve-rs/Makefile
+++ b/pve-rs/Makefile
@@ -20,6 +20,7 @@ PM_DIRS := \
PM_FILES := \
PVE/RS/APT/Repositories.pm \
+ PVE/RS/CalendarEvent.pm \
PVE/RS/OpenId.pm \
PVE/RS/TFA.pm
diff --git a/pve-rs/src/calendar_event.rs b/pve-rs/src/calendar_event.rs
new file mode 100644
index 0000000..b898b15
--- /dev/null
+++ b/pve-rs/src/calendar_event.rs
@@ -0,0 +1,20 @@
+#[perlmod::package(name = "${PERLMOD_PRODUCT}::RS::CalendarEvent")]
+mod export {
+ use anyhow::Error;
+ use perlmod::Value;
+
+ perlmod::declare_magic!(Box<CalendarEvent> : &CalendarEvent as "${PERLMOD_PRODUCT}::RS::CalendarEvent");
+
+ #[repr(transparent)]
+ struct CalendarEvent(proxmox_time::CalendarEvent);
+
+ #[export(raw_return)]
+ fn new(#[raw] class: Value, event: String) -> Result<Value, Error> {
+ Ok(perlmod::instantiate_magic!(&class, MAGIC => Box::new(CalendarEvent(event.parse()?))))
+ }
+
+ #[export]
+ fn compute_next_event(#[try_from_ref] this: &CalendarEvent, last: i64) -> Result<Option<i64>, Error> {
+ this.0.compute_next_event(last)
+ }
+}
diff --git a/pve-rs/src/lib.rs b/pve-rs/src/lib.rs
index 594a96f..2c25ee1 100644
--- a/pve-rs/src/lib.rs
+++ b/pve-rs/src/lib.rs
@@ -5,3 +5,4 @@ pub mod apt;
pub mod openid;
pub mod tfa;
+pub mod calendar_event;
--
2.30.2
next prev parent reply other threads:[~2021-12-01 8:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 8:55 [pve-devel] [PATCH proxmox-perl-rs/common] use calendar-events from rust Dominik Csapak
2021-12-01 8:55 ` Dominik Csapak [this message]
2021-12-01 8:55 ` [pve-devel] [PATCH common 1/1] CalendarEvent: use rust implementation Dominik Csapak
2022-01-13 16:20 ` Thomas Lamprecht
2022-01-13 14:45 ` [pve-devel] applied-series: [PATCH proxmox-perl-rs/common] use calendar-events from rust Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211201085514.1648428-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal