• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davidcole1340 / ext-php-rs / 14649493721

24 Apr 2025 06:56PM CUT coverage: 14.14% (+0.01%) from 14.129%
14649493721

Pull #426

github

Xenira
refactor(macro): use `#[php]` attribute for startup function

This unifies the behaviour of the `#[php_module]` macro and the other `#[php_*]` macros.

Refs: #423
Pull Request #426: refactor(macro): use `#[php]` attribute for startup function

0 of 5 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

553 of 3911 relevant lines covered (14.14%)

1.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/crates/cli/src/ext.rs
1
use std::path::PathBuf;
2

3
use anyhow::{Context, Result};
4
use ext_php_rs::describe::Description;
5
use libloading::os::unix::{Library, Symbol};
6

7
#[allow(improper_ctypes_definitions)]
8
pub struct Ext {
9
    // These need to be here to keep the libraries alive. The extension library needs to be alive
10
    // to access the describe function. Missing here is the lifetime on `Symbol<'a, fn() ->
11
    // Module>` where `ext_lib: 'a`.
12
    #[allow(dead_code)]
13
    ext_lib: Library,
14
    describe_fn: Symbol<extern "C" fn() -> Description>,
15
}
16

17
impl Ext {
18
    /// Loads an extension.
19
    pub fn load(ext_path: PathBuf) -> Result<Self> {
×
20
        let ext_lib = unsafe { Library::new(ext_path) }
×
21
            .with_context(|| "Failed to load extension library")?;
×
22

23
        let describe_fn = unsafe {
24
            ext_lib
×
25
                .get(b"ext_php_rs_describe_module")
26
                .with_context(|| "Failed to load describe function symbol from extension library")?
×
27
        };
28

29
        Ok(Self {
×
30
            ext_lib,
×
31
            describe_fn,
×
32
        })
33
    }
34

35
    /// Describes the extension.
36
    pub fn describe(&self) -> Description {
×
37
        (self.describe_fn)()
×
38
    }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc