add common-src/ and move CalendarEvent to it

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-02-25 15:40:00 +01:00
parent f939c2bb55
commit ba8dad1190
10 changed files with 22 additions and 13 deletions

View File

@ -1,5 +1,5 @@
[workspace]
exclude = [ "build" ]
exclude = [ "build", "common-src", "perl" ]
members = [
"pve-rs",
"pmg-rs",

View File

@ -26,8 +26,11 @@ pve pmg:
build:
mkdir build
echo system >build/rust-toolchain
cp -a ./common-src ./build
cp -a ./pve-rs ./build
cp -a ./pmg-rs ./build
cp -a ./perl ./build/pve-rs
cp -a ./perl ./build/pmg-rs
pve-deb: build
cd ./build/pve-rs && dpkg-buildpackage -b -uc -us

View File

@ -1,9 +1,9 @@
#[perlmod::package(name = "${PERLMOD_PRODUCT}::RS::CalendarEvent")]
#[perlmod::package(name = "Proxmox::RS::CalendarEvent")]
mod export {
use anyhow::Error;
use perlmod::Value;
perlmod::declare_magic!(Box<CalendarEvent> : &CalendarEvent as "${PERLMOD_PRODUCT}::RS::CalendarEvent");
perlmod::declare_magic!(Box<CalendarEvent> : &CalendarEvent as "Proxmox::RS::CalendarEvent");
#[repr(transparent)]
struct CalendarEvent(proxmox_time::CalendarEvent);
@ -14,7 +14,10 @@ mod export {
}
#[export]
fn compute_next_event(#[try_from_ref] this: &CalendarEvent, last: i64) -> Result<Option<i64>, Error> {
fn compute_next_event(
#[try_from_ref] this: &CalendarEvent,
last: i64,
) -> Result<Option<i64>, Error> {
this.0.compute_next_event(last)
}
}

1
common/src/mod.rs Normal file
View File

@ -0,0 +1 @@
mod calendar_event;

View File

@ -33,3 +33,4 @@ perlmod = { version = "0.12", features = [ "exporter" ] }
proxmox-acme-rs = { version = "0.4", features = ["client"] }
proxmox-apt = "0.8.0"
proxmox-tfa = { version = "2", features = ["api"] }
proxmox-time = "1.1.3"

View File

@ -179,7 +179,7 @@ impl Inner {
}
}
#[perlmod::package(name = "PMG::RS::Acme", lib = "pmg_rs")]
#[perlmod::package(name = "PMG::RS::Acme")]
pub mod export {
use std::collections::HashMap;
use std::convert::TryFrom;
@ -426,5 +426,4 @@ pub mod export {
pub fn set_proxy(#[try_from_ref] this: &Acme, proxy: String) {
this.inner.lock().unwrap().set_proxy(proxy)
}
}

View File

@ -1,4 +1,4 @@
#[perlmod::package(name = "PMG::RS::APT::Repositories", lib = "pmg_rs")]
#[perlmod::package(name = "PMG::RS::APT::Repositories")]
mod export {
use std::convert::TryInto;

View File

@ -1,4 +1,4 @@
#[perlmod::package(name = "PMG::RS::CSR", lib = "pmg_rs")]
#[perlmod::package(name = "PMG::RS::CSR")]
pub mod export {
use std::collections::HashMap;
@ -16,9 +16,6 @@ pub mod export {
attributes: HashMap<String, &str>,
) -> Result<(ByteBuf, ByteBuf), Error> {
let csr = Csr::generate(&identifiers, &attributes)?;
Ok((
ByteBuf::from(csr.data),
ByteBuf::from(csr.private_key_pem),
))
Ok((ByteBuf::from(csr.data), ByteBuf::from(csr.private_key_pem)))
}
}

View File

@ -1,3 +1,6 @@
#[path = "../../common/src/mod.rs"]
pub mod common;
pub mod acme;
pub mod apt;
pub mod csr;

View File

@ -1,6 +1,8 @@
//! Rust library for the Proxmox VE code base.
#[path = "../../common/src/mod.rs"]
pub mod common;
pub mod apt;
pub mod openid;
pub mod tfa;
pub mod calendar_event;