use std::sync::Arc;
use crate::env::KeyLike;
use crate::piet::{PietTextLayoutBuilder, TextStorage as PietTextStorage};
use crate::{Data, Env};
use super::attribute::Link;
use crate::UpdateCtx;
pub trait TextStorage: PietTextStorage + Data {
#[allow(unused_variables)]
fn add_attributes(&self, builder: PietTextLayoutBuilder, env: &Env) -> PietTextLayoutBuilder {
builder
}
#[allow(unused_variables)]
fn env_update(&self, ctx: &EnvUpdateCtx) -> bool {
false
}
fn links(&self) -> &[Link] {
&[]
}
}
pub struct EnvUpdateCtx<'a, 'b>(&'a UpdateCtx<'a, 'b>);
impl<'a, 'b> EnvUpdateCtx<'a, 'b> {
pub(crate) fn for_update(ctx: &'a UpdateCtx<'a, 'b>) -> Self {
Self(ctx)
}
pub fn env_key_changed<T>(&self, key: &impl KeyLike<T>) -> bool {
self.0.env_key_changed(key)
}
}
pub type ArcStr = Arc<str>;
impl TextStorage for ArcStr {}
impl TextStorage for String {}
impl TextStorage for Arc<String> {}