FeishuCard

Struct FeishuCard 

Source
pub struct FeishuCard {
    pub config: Option<FeishuCardConfig>,
    pub i18n_header: HashMap<FeishuCardLanguage, FeishuCardTitle>,
    pub i18n_elements: HashMap<FeishuCardLanguage, Vec<CardElement>>,
}
Expand description

飞书消息卡片

用于创建和发送交互式消息卡片。支持多语言、富文本、交互组件等丰富功能。 卡片可以包含文本、图片、按钮、表单等多种组件,提供丰富的用户交互体验。

§主要特性

  • 🌐 多语言支持
  • 🎨 丰富的UI组件
  • 🔄 交互式操作
  • 📱 响应式布局
  • 🔧 高度可定制

§支持的组件

  • 文本组件: 纯文本、富文本、标题
  • 媒体组件: 图片、视频
  • 交互组件: 按钮、输入框、选择器
  • 布局组件: 分栏、折叠面板
  • 数据组件: 表格、图表

§示例

use open_lark::card::{FeishuCard, FeishuCardConfig};
use open_lark::card::components::content_components::title::FeishuCardTitle;
use open_lark::card::components::content_components::title::Title;
use open_lark::card::components::CardElement;

// 创建简单卡片
let card = FeishuCard::new()
    .config(
        FeishuCardConfig::new()
            .enable_forward(true)
            .update_multi(false)
    )
    .header("zh_cn",
        FeishuCardTitle::new()
            .title(Title::new("欢迎使用飞书卡片"))
    )?
    .elements("zh_cn", vec![
        // 添加卡片元素
    ])?;

Fields§

§config: Option<FeishuCardConfig>

config 用于配置卡片的全局行为,包括是否允许被转发、是否为共享卡片等。

§i18n_header: HashMap<FeishuCardLanguage, FeishuCardTitle>

用于配置卡片的标题

§i18n_elements: HashMap<FeishuCardLanguage, Vec<CardElement>>

卡片的多语言正文内容

Implementations§

Source§

impl FeishuCard

Source

pub fn new() -> Self

创建新的飞书卡片

默认使用中文语言环境,创建包含默认标题和空元素列表的卡片。

Source

pub fn config(self, config: FeishuCardConfig) -> Self

设置卡片全局配置

§参数
  • config - 卡片配置对象
Source

pub fn header( self, lng: &str, header: FeishuCardTitle, ) -> Result<Self, LarkAPIError>

设置卡片标题

§参数
  • lng - 语言代码 (如 “zh_cn”, “en_us”)
  • header - 卡片标题对象
Source

pub fn elements( self, lng: &str, elements: Vec<CardElement>, ) -> Result<Self, LarkAPIError>

添加卡片组件

§参数
  • lng - 语言代码 (如 “zh_cn”, “en_us”)
  • elements - 卡片组件列表

Trait Implementations§

Source§

impl Debug for FeishuCard

Source§

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

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

impl Default for FeishuCard

Source§

fn default() -> FeishuCard

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FeishuCard

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl SendMessageTrait for FeishuCard

Available on crate feature im only.
Source§

fn msg_type(&self) -> String

获取消息类型 Read more
Source§

fn content(&self) -> String

获取消息内容 Read more
Source§

impl Serialize for FeishuCard

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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