Skip to main content

Cell

Struct Cell 

Source
pub struct Cell { /* private fields */ }
Expand description

A table cell. Use Cell::header for <th>; colspan/rowspan map to the matching HTML attributes. Cell content is escaped unless you pass SummaryText::html.

§Examples

use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::header("Name"), Cell::new("value")]]);
assert!(s.stringify().contains(r#"<th colspan="1" rowspan="1">Name</th>"#));

Implementations§

Source§

impl Cell

Source

pub fn new(data: impl Into<SummaryText>) -> Self

A <td> cell.

§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::new("x")]]);
assert_eq!(s.stringify(), "<table><tr><td colspan=\"1\" rowspan=\"1\">x</td></tr></table>\n");
Examples found in repository?
examples/demo.rs (line 68)
13fn main() {
14    log::info(format!(
15        "in GitHub Actions: {} | CI: {} | step-debug: {}",
16        env::is_github_actions(),
17        env::is_ci(),
18        log::is_debug()
19    ));
20
21    let ctx = actions_rs::Context::new();
22    log::info(format!(
23        "repo={:?} ref={:?} sha={:?}",
24        ctx.repository(),
25        ctx.ref_name(),
26        ctx.sha()
27    ));
28
29    // Located annotation with a line range — should print:
30    // ::warning title=demo,file=src/lib.rs,line=10,endLine=12::heads up
31    Annotation::new()
32        .file("src/lib.rs")
33        .line(10)
34        .end_line(12)
35        .title("demo")
36        .warning("heads up: this span looks suspicious");
37
38    // Escaping check: newline in data, colon/comma in a property.
39    Annotation::new()
40        .title("type: mismatch, really")
41        .error("line one\nline two");
42
43    let total = log::group("expensive step", || {
44        log::info("...working...");
45        2 + 2
46    });
47    log::info(format!("group returned {total}"));
48
49    actions_rs::warning!("formatted macro: {} items left", 7);
50
51    output::set_output("answer", 42).expect("set_output");
52    match output::export_var("DEMO_FLAG", true) {
53        Ok(()) => {}
54        Err(actions_rs::Error::UnavailableFileCommand {
55            var: "GITHUB_ENV", ..
56        }) => {
57            log::info("GITHUB_ENV unset; skipping export_var in local demo");
58        }
59        Err(err) => panic!("export_var: {err}"),
60    }
61
62    let mut summary = Summary::new();
63    summary
64        .heading("Demo Report", 2)
65        .raw("Built by the `demo` example.", true)
66        .table([
67            vec![Cell::header("Check"), Cell::header("Result")],
68            vec![Cell::new("clippy"), Cell::new("pass")],
69            vec![Cell::new("tests"), Cell::new("36 pass")],
70        ])
71        .code_block("cargo test", Some("sh"));
72    summary.write().expect("write summary");
73    log::info("summary written (if GITHUB_STEP_SUMMARY was set)");
74}
Source

pub fn header(data: impl Into<SummaryText>) -> Self

A <th> header cell.

§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::header("Col")]]);
assert_eq!(s.stringify(), "<table><tr><th colspan=\"1\" rowspan=\"1\">Col</th></tr></table>\n");
Examples found in repository?
examples/demo.rs (line 67)
13fn main() {
14    log::info(format!(
15        "in GitHub Actions: {} | CI: {} | step-debug: {}",
16        env::is_github_actions(),
17        env::is_ci(),
18        log::is_debug()
19    ));
20
21    let ctx = actions_rs::Context::new();
22    log::info(format!(
23        "repo={:?} ref={:?} sha={:?}",
24        ctx.repository(),
25        ctx.ref_name(),
26        ctx.sha()
27    ));
28
29    // Located annotation with a line range — should print:
30    // ::warning title=demo,file=src/lib.rs,line=10,endLine=12::heads up
31    Annotation::new()
32        .file("src/lib.rs")
33        .line(10)
34        .end_line(12)
35        .title("demo")
36        .warning("heads up: this span looks suspicious");
37
38    // Escaping check: newline in data, colon/comma in a property.
39    Annotation::new()
40        .title("type: mismatch, really")
41        .error("line one\nline two");
42
43    let total = log::group("expensive step", || {
44        log::info("...working...");
45        2 + 2
46    });
47    log::info(format!("group returned {total}"));
48
49    actions_rs::warning!("formatted macro: {} items left", 7);
50
51    output::set_output("answer", 42).expect("set_output");
52    match output::export_var("DEMO_FLAG", true) {
53        Ok(()) => {}
54        Err(actions_rs::Error::UnavailableFileCommand {
55            var: "GITHUB_ENV", ..
56        }) => {
57            log::info("GITHUB_ENV unset; skipping export_var in local demo");
58        }
59        Err(err) => panic!("export_var: {err}"),
60    }
61
62    let mut summary = Summary::new();
63    summary
64        .heading("Demo Report", 2)
65        .raw("Built by the `demo` example.", true)
66        .table([
67            vec![Cell::header("Check"), Cell::header("Result")],
68            vec![Cell::new("clippy"), Cell::new("pass")],
69            vec![Cell::new("tests"), Cell::new("36 pass")],
70        ])
71        .code_block("cargo test", Some("sh"));
72    summary.write().expect("write summary");
73    log::info("summary written (if GITHUB_STEP_SUMMARY was set)");
74}
Source

pub fn colspan(self, n: u32) -> Self

Set the column span (clamped to ≥ 1; the HTML spec forbids 0).

§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::new("wide").colspan(0)]]); // 0 clamps to 1
assert!(s.stringify().contains(r#"colspan="1""#));
Source

pub fn rowspan(self, n: u32) -> Self

Set the row span (clamped to ≥ 1; the HTML spec forbids 0).

§Examples
use actions_rs::{Cell, Summary};
let mut s = Summary::new();
s.table([vec![Cell::new("tall").rowspan(3)]]);
assert!(s.stringify().contains(r#"rowspan="3""#));

Trait Implementations§

Source§

impl Clone for Cell

Source§

fn clone(&self) -> Cell

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cell

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for Cell

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Cell

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<SummaryText> for Cell

Source§

fn from(text: SummaryText) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Cell

§

impl RefUnwindSafe for Cell

§

impl Send for Cell

§

impl Sync for Cell

§

impl Unpin for Cell

§

impl UnsafeUnpin for Cell

§

impl UnwindSafe for Cell

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.