TranslationBindingSource
struct · ferroui-protranslate · v0.5.0
struct TranslationBindingSource
A replaceable translation service shared by native bindings and attached targets.
Cloning shares the source, while set_service atomically
replaces its service and refreshes existing bindings. The source owns no UI
target, and subscription handles unsubscribe both on disposal and on drop.
Members
newserviceset_servicecultureformatting_cultureset_cultureset_culturestranslateget_valueis_disposeddisposerefreshsubscriber_countsubscribeobservedefault_sourceuse_default_source
new
fn new(service: TranslationService) -> Self
service
fn service(self: &Self) -> TranslationService
set_service
fn set_service(self: &Self, service: TranslationService)
culture
fn culture(self: &Self) -> Culture
Culture used to select resources and resolve text direction.
formatting_culture
fn formatting_culture(self: &Self) -> Culture
Culture used for numeric, date and measurement formatting.
set_culture
fn set_culture(self: &Self, culture: Culture) -> bool
set_cultures
fn set_cultures(self: &Self, culture: Culture, ui_culture: Culture) -> bool
translate
fn translate(self: &Self, key: &str, arguments: &[FormatArgument]) -> Result<String, TranslationError>
Direct translation preserves the core missing-key and formatting policies.
get_value
fn get_value(self: &Self, key: &str) -> Result<Option<BoxedValue>, TranslationError>
The native binding indexer yields UnsetValue for a missing resource so the binding engine can apply its fallback or the target property's default.
is_disposed
fn is_disposed(self: &Self) -> bool
dispose
fn dispose(self: &Self)
Disconnects this source from its service. Dropping its final clone also releases the service subscription without requiring explicit disposal.
refresh
fn refresh(self: &Self)
Explicitly re-evaluates consumers after application-owned catalog updates.
subscriber_count
fn subscriber_count(self: &Self) -> usize
Number of live native consumers, useful for lifecycle diagnostics.
subscribe
fn subscribe(self: &Self, handler: impl Fn() -> () + 'static) -> Rc<dyn IDisposable>
Observes refreshes. A subscription never retains its source.
observe
fn observe(self: &Self, key: impl Into<String>, arguments: Vec<FormatArgument>) -> Rc<dyn IObservable<String>>
A native observable suitable for FerroUI's typed property bindings.
default_source
fn default_source() -> Self
The explicitly configured, UI-thread-local default source. Initially an empty catalog using the framework's current UI culture.
use_default_source
fn use_default_source(source: Self)
Replaces the ambient source and reconnects existing unscoped consumers. Independently scoped users of the old source keep their own source alive.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedPropertyValueAnyValueClassDefaultsErasedDestructorIntoEitherClonePartialEqEqINotifyPropertyChangedIDisposableMarkupTyped
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.