Select

Struct Select 

Source
pub struct Select<E>
where E: EntityTrait,
{ /* private fields */ }
Expand description

Defines a structure to perform select operations

Implementations§

Source§

impl<E, M> Select<E>
where E: EntityTrait<Model = M>, M: FromQueryResult + Send + Sync,

Source

pub fn cursor_by<C>(self, order_columns: C) -> Cursor<SelectModel<M>>
where C: IntoIdentity,

Convert into a cursor

Source§

impl<E> Select<E>
where E: EntityTrait,

Source

pub fn from_raw_sql( self, stmt: Statement, ) -> SelectorRaw<SelectModel<<E as EntityTrait>::Model>>

Perform a Select operation on a Model using a Statement

Source

pub fn into_model<M>(self) -> Selector<SelectModel<M>>
where M: FromQueryResult,

Return a Selector from Self that wraps a SelectModel

Source

pub fn into_partial_model<M>(self) -> Selector<SelectModel<M>>

Return a Selector from Self that wraps a SelectModel with a PartialModel

use sea_orm::{
    entity::*,
    query::*,
    tests_cfg::cake::{self, Entity as Cake},
    DbBackend, DerivePartialModel, FromQueryResult,
};
use sea_query::{Expr, Func, SimpleExpr};

#[derive(DerivePartialModel, FromQueryResult)]
#[sea_orm(entity = "Cake")]
struct PartialCake {
    name: String,
    #[sea_orm(
        from_expr = r#"SimpleExpr::FunctionCall(Func::upper(Expr::col((Cake, cake::Column::Name))))"#
    )]
    name_upper: String,
}

assert_eq!(
    cake::Entity::find()
        .into_partial_model::<PartialCake>()
        .into_statement(DbBackend::Sqlite)
        .to_string(),
    r#"SELECT "cake"."name" AS "name", UPPER("cake"."name") AS "name_upper" FROM "cake""#
);
Source

pub fn into_json(self) -> Selector<SelectModel<Value>>

Get a selectable Model as a JsonValue for SQL JSON operations

Source

pub fn into_values<T, C>(self) -> Selector<SelectGetableValue<T, C>>

use sea_orm::{entity::*, query::*, tests_cfg::cake, DeriveColumn, EnumIter};

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
enum QueryAs {
    CakeName,
}

let res: Vec<String> = cake::Entity::find()
    .select_only()
    .column_as(cake::Column::Name, QueryAs::CakeName)
    .into_values::<_, QueryAs>()
    .all(&db)
    .await?;

assert_eq!(
    res,
    ["Chocolate Forest".to_owned(), "New York Cheese".to_owned()]
);

assert_eq!(
    db.into_transaction_log(),
    [Transaction::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."name" AS "cake_name" FROM "cake""#,
        []
    )]
);
use sea_orm::{entity::*, query::*, tests_cfg::cake, DeriveColumn, EnumIter};

#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
enum QueryAs {
    CakeName,
    NumOfCakes,
}

let res: Vec<(String, i64)> = cake::Entity::find()
    .select_only()
    .column_as(cake::Column::Name, QueryAs::CakeName)
    .column_as(cake::Column::Id.count(), QueryAs::NumOfCakes)
    .group_by(cake::Column::Name)
    .into_values::<_, QueryAs>()
    .all(&db)
    .await?;

assert_eq!(res, [("Chocolate Forest".to_owned(), 2i64)]);

assert_eq!(
    db.into_transaction_log(),
    [Transaction::from_sql_and_values(
        DbBackend::Postgres,
        [
            r#"SELECT "cake"."name" AS "cake_name", COUNT("cake"."id") AS "num_of_cakes""#,
            r#"FROM "cake" GROUP BY "cake"."name""#,
        ]
        .join(" ")
        .as_str(),
        []
    )]
);
Source

pub fn into_tuple<T>(self) -> Selector<SelectGetableTuple<T>>
where T: TryGetableMany,

use sea_orm::{entity::*, query::*, tests_cfg::cake};

let res: Vec<String> = cake::Entity::find()
    .select_only()
    .column(cake::Column::Name)
    .into_tuple()
    .all(&db)
    .await?;

assert_eq!(
    res,
    vec!["Chocolate Forest".to_owned(), "New York Cheese".to_owned()]
);

assert_eq!(
    db.into_transaction_log(),
    vec![Transaction::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."name" FROM "cake""#,
        vec![]
    )]
);
use sea_orm::{entity::*, query::*, tests_cfg::cake};

let res: Vec<(String, i64)> = cake::Entity::find()
    .select_only()
    .column(cake::Column::Name)
    .column(cake::Column::Id)
    .group_by(cake::Column::Name)
    .into_tuple()
    .all(&db)
    .await?;

assert_eq!(res, vec![("Chocolate Forest".to_owned(), 2i64)]);

assert_eq!(
    db.into_transaction_log(),
    vec![Transaction::from_sql_and_values(
        DbBackend::Postgres,
        vec![
            r#"SELECT "cake"."name", "cake"."id""#,
            r#"FROM "cake" GROUP BY "cake"."name""#,
        ]
        .join(" ")
        .as_str(),
        vec![]
    )]
);
Source

pub async fn one<C>( self, db: &C, ) -> Result<Option<<E as EntityTrait>::Model>, DbErr>
where C: ConnectionTrait,

Get one Model from the SELECT query

Source

pub async fn all<C>( self, db: &C, ) -> Result<Vec<<E as EntityTrait>::Model>, DbErr>
where C: ConnectionTrait,

Get all Models from the SELECT query

Source

pub async fn stream<'a, 'b, C>( self, db: &'a C, ) -> Result<impl Stream<Item = Result<<E as EntityTrait>::Model, DbErr>> + Send + 'b, DbErr>
where 'a: 'b, C: ConnectionTrait + StreamTrait + Send,

Stream the results of a SELECT operation on a Model

Source

pub async fn stream_partial_model<'a, 'b, C, M>( self, db: &'a C, ) -> Result<impl Stream<Item = Result<M, DbErr>> + Send + 'b, DbErr>
where 'a: 'b, C: ConnectionTrait + StreamTrait + Send, M: PartialModelTrait + Send + 'b,

Stream the result of the operation with PartialModel

Source§

impl<E> Select<E>
where E: EntityTrait,

Source

pub fn select_also<F>(self, _: F) -> SelectTwo<E, F>
where F: EntityTrait,

Selects extra Entity and returns it together with the Entity from Self

Source

pub fn select_with<F>(self, _: F) -> SelectTwoMany<E, F>
where F: EntityTrait,

Makes a SELECT operation in conjunction to another relation

Source§

impl<E> Select<E>
where E: EntityTrait,

Source

pub fn left_join<R>(self, _: R) -> Select<E>
where R: EntityTrait, E: Related<R>,

Left Join with a Related Entity.

Source

pub fn right_join<R>(self, _: R) -> Select<E>
where R: EntityTrait, E: Related<R>,

Right Join with a Related Entity.

Source

pub fn inner_join<R>(self, _: R) -> Select<E>
where R: EntityTrait, E: Related<R>,

Inner Join with a Related Entity.

Source

pub fn reverse_join<R>(self, _: R) -> Select<E>
where R: EntityTrait + Related<E>,

Join with an Entity Related to me.

Left Join with a Related Entity and select both Entity.

Left Join with a Related Entity and select the related Entity as a Vec

Source

pub fn find_also_linked<L, T>(self, l: L) -> SelectTwo<E, T>
where L: Linked<FromEntity = E, ToEntity = T>, T: EntityTrait,

Left Join with a Linked Entity and select both Entity.

Source

pub fn find_with_linked<L, T>(self, l: L) -> SelectTwoMany<E, T>
where L: Linked<FromEntity = E, ToEntity = T>, T: EntityTrait,

Left Join with a Linked Entity and select Entity as a Vec.

Trait Implementations§

Source§

impl<E> Clone for Select<E>
where E: Clone + EntityTrait,

Source§

fn clone(&self) -> Select<E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<E, M> CursorTrait for Select<E>
where E: EntityTrait<Model = M>, M: FromQueryResult + Send + Sync,

Source§

type Selector = SelectModel<M>

Select operation
Source§

impl<E> Debug for Select<E>
where E: Debug + EntityTrait,

Source§

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

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

impl<E> EntityOrSelect<E> for Select<E>
where E: EntityTrait,

Source§

fn select(self) -> Select<E>

If self is Entity, use Entity::find()
Source§

impl<'db, C, M, E> PaginatorTrait<'db, C> for Select<E>
where C: ConnectionTrait, E: EntityTrait<Model = M>, M: FromQueryResult + Send + Sync + 'db,

Source§

type Selector = SelectModel<M>

Select operation
Source§

fn paginate( self, db: &'db C, page_size: u64, ) -> Paginator<'db, C, <Select<E> as PaginatorTrait<'db, C>>::Selector>

Paginate the result of a select operation.
Source§

fn count<'async_trait>( self, db: &'db C, ) -> Pin<Box<dyn Future<Output = Result<u64, DbErr>> + Send + 'async_trait>>
where 'db: 'async_trait, Self: Sized + Send + 'async_trait,

Perform a count on the paginated results
Source§

impl<E> QueryFilter for Select<E>
where E: EntityTrait,

Source§

type QueryStatement = SelectStatement

Source§

fn query(&mut self) -> &mut SelectStatement

Add the query to perform a FILTER on
Source§

fn filter<F>(self, filter: F) -> Self
where F: IntoCondition,

Add an AND WHERE expression Read more
Source§

fn belongs_to<M>(self, model: &M) -> Self
where M: ModelTrait,

Apply a where condition using the model’s primary key
Source§

fn belongs_to_tbl_alias<M>(self, model: &M, tbl_alias: &str) -> Self
where M: ModelTrait,

Perform a check to determine table belongs to a Model through it’s name alias
Source§

impl<E> QueryOrder for Select<E>
where E: EntityTrait,

Source§

type QueryStatement = SelectStatement

Source§

fn query(&mut self) -> &mut SelectStatement

Add the query to perform an ORDER BY operation
Source§

fn order_by<C>(self, col: C, ord: Order) -> Self
where C: IntoSimpleExpr,

Add an order_by expression Read more
Source§

fn order_by_asc<C>(self, col: C) -> Self
where C: IntoSimpleExpr,

Add an order_by expression (ascending) Read more
Source§

fn order_by_desc<C>(self, col: C) -> Self
where C: IntoSimpleExpr,

Add an order_by expression (descending) Read more
Source§

fn order_by_with_nulls<C>(self, col: C, ord: Order, nulls: NullOrdering) -> Self
where C: IntoSimpleExpr,

Add an order_by expression with nulls ordering option Read more
Source§

impl<E> QuerySelect for Select<E>
where E: EntityTrait,

Source§

type QueryStatement = SelectStatement

Source§

fn query(&mut self) -> &mut SelectStatement

Add the select SQL statement
Source§

fn select_only(self) -> Self

Clear the selection list
Source§

fn column<C>(self, col: C) -> Self
where C: ColumnTrait,

Add a select column Read more
Source§

fn column_as<C, I>(self, col: C, alias: I) -> Self

Add a select column with alias Read more
Source§

fn columns<C, I>(self, cols: I) -> Self
where C: ColumnTrait, I: IntoIterator<Item = C>,

Select columns Read more
Source§

fn offset<T>(self, offset: T) -> Self
where T: Into<Option<u64>>,

Add an offset expression. Passing in None would remove the offset. Read more
Source§

fn limit<T>(self, limit: T) -> Self
where T: Into<Option<u64>>,

Add a limit expression. Passing in None would remove the limit. Read more
Source§

fn group_by<C>(self, col: C) -> Self
where C: IntoSimpleExpr,

Add a group by column Read more
Source§

fn having<F>(self, filter: F) -> Self
where F: IntoCondition,

Add an AND HAVING expression Read more
Source§

fn distinct(self) -> Self

Add a DISTINCT expression Read more
Source§

fn distinct_on<T, I>(self, cols: I) -> Self
where T: IntoColumnRef, I: IntoIterator<Item = T>,

Add a DISTINCT ON expression NOTE: this function is only supported by sqlx-postgres Read more
Source§

fn join(self, join: JoinType, rel: RelationDef) -> Self

Join via RelationDef.
Source§

fn join_rev(self, join: JoinType, rel: RelationDef) -> Self

Join via RelationDef but in reverse direction. Assume when there exist a relation A to B. You can reverse join B from A.
Source§

fn join_as<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Self
where I: IntoIden,

Join via RelationDef with table alias.
Source§

fn join_as_rev<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Self
where I: IntoIden,

Join via RelationDef with table alias but in reverse direction. Assume when there exist a relation A to B. You can reverse join B from A.
Source§

fn lock(self, lock_type: LockType) -> Self

Select lock
Source§

fn lock_shared(self) -> Self

Select lock shared
Source§

fn lock_exclusive(self) -> Self

Select lock exclusive
Source§

fn lock_with_behavior(self, type: LockType, behavior: LockBehavior) -> Self

Row locking with behavior (if supported). Read more
Source§

fn expr<T>(self, expr: T) -> Self
where T: Into<SelectExpr>,

Add an expression to the select expression list. Read more
Source§

fn exprs<T, I>(self, exprs: I) -> Self
where T: Into<SelectExpr>, I: IntoIterator<Item = T>,

Add select expressions from vector of SelectExpr. Read more
Source§

fn expr_as<T, A>(self, expr: T, alias: A) -> Self

Select column. Read more
Source§

fn expr_as_<T, A>(self, expr: T, alias: A) -> Self

Same as expr_as. Here for legacy reasons. Read more
Source§

fn tbl_col_as<T, C, A>(self, _: (T, C), alias: A) -> Self
where T: IntoIden + 'static, C: IntoIden + 'static, A: IntoIdentity,

Shorthand of expr_as(Expr::col((T, C)), A). Read more
Source§

impl<E> QueryTrait for Select<E>
where E: EntityTrait,

Source§

type QueryStatement = SelectStatement

Constrain the QueryStatement to QueryStatementBuilder trait
Source§

fn query(&mut self) -> &mut SelectStatement

Get a mutable ref to the query builder
Source§

fn as_query(&self) -> &SelectStatement

Get an immutable ref to the query builder
Source§

fn into_query(self) -> SelectStatement

Take ownership of the query builder
Source§

fn build(&self, db_backend: DatabaseBackend) -> Statement

Build the query as Statement
Source§

fn apply_if<T, F>(self, val: Option<T>, if_some: F) -> Self
where Self: Sized, F: FnOnce(Self, T) -> Self,

Apply an operation on the QueryTrait::QueryStatement if the given Option<T> is Some(_) Read more

Auto Trait Implementations§

§

impl<E> Freeze for Select<E>

§

impl<E> !RefUnwindSafe for Select<E>

§

impl<E> Send for Select<E>

§

impl<E> Sync for Select<E>

§

impl<E> Unpin for Select<E>
where E: Unpin,

§

impl<E> !UnwindSafe for Select<E>

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S> SelectColumns for S
where S: QuerySelect,

Source§

fn select_column<C>(self, col: C) -> S
where C: ColumnTrait,

Add a select column Read more
Source§

fn select_column_as<C, I>(self, col: C, alias: I) -> S

Add a select column with alias Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,