pub struct RowLink<M> { /* private fields */ }Expand description
A link among a row’s actions, such as a product’s storefront page: unlike an
Action, it posts nothing and runs no policy check, so it suits only a page
the user may already open.
use tablo_core::{Reads, RowLink, Table, TextColumn, lens};
Table::new(TextColumn::new(lens!(Product.name))).row_link(
RowLink::new("Open product", |product: &Product| {
Some(format!("/shop/{}", product.slug))
})
.new_tab()
.reading(Reads::of(lens!(Product.slug))),
);Implementations§
Source§impl<M> RowLink<M>
impl<M> RowLink<M>
Sourcepub fn new(
label: impl Into<Text>,
url: impl Fn(&M) -> Option<String> + Send + Sync + 'static,
) -> Self
pub fn new( label: impl Into<Text>, url: impl Fn(&M) -> Option<String> + Send + Sync + 'static, ) -> Self
A link reading label to url(row); a row it gives None shows no link. The URL is
relative, or absolute over http, https, mailto or tel: a row whose URL has any
other scheme, such as javascript:, shows no link either.
Sourcepub fn reading(self, reads: Reads<M>) -> Self
pub fn reading(self, reads: Reads<M>) -> Self
Declare the fields the URL reads. A resource that restricts a field refuses the table until each of its links declares them, and a user who may not view one of them sees no such link.
Trait Implementations§
Auto Trait Implementations§
impl<M> !RefUnwindSafe for RowLink<M>
impl<M> !UnwindSafe for RowLink<M>
impl<M> Forget for RowLink<M>
impl<M> Freeze for RowLink<M>
impl<M> Send for RowLink<M>
impl<M> Sync for RowLink<M>
impl<M> Unpin for RowLink<M>
impl<M> UnsafeUnpin for RowLink<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more