StudioDocument
struct · ferroui-protranslate-studio · v0.5.0
struct StudioDocument
An owned document; hosts decide how to expose notifications and selection.
Members
newfrom_sessionrestoresessionsnapshotcatalogis_dirtymark_savedgenerationundo_countredo_countset_history_limitentryfiltered_idsmetricscoverageset_targetset_notesset_reviewreplace_entryadd_entrydelete_entryadd_target_cultureset_target_cultureexportmaterialize_target_culturecatalog_with_review_statesentry_diagnosticstransactionundoredoprepare_translationprepare_missing_translationsaccept_suggestionaccept_suggestions
new
fn new(session_id: impl Into<String>, imported: ImportedCatalog, now_millis: i64) -> Result<Self, StudioError>
from_session
fn from_session(session: TranslationSession) -> Result<Self, StudioError>
restore
fn restore(self: &mut Self, session: TranslationSession, recovered: bool) -> Result<(), StudioError>
session
fn session(self: &Self) -> &TranslationSession
snapshot
fn snapshot(self: &Self, now_millis: i64) -> TranslationSession
catalog
fn catalog(self: &Self) -> &TranslationCatalog
is_dirty
fn is_dirty(self: &Self) -> bool
mark_saved
fn mark_saved(self: &mut Self, snapshot: &TranslationSession) -> bool
Call only after the host successfully persisted this exact snapshot.
generation
fn generation(self: &Self) -> u64
undo_count
fn undo_count(self: &Self) -> usize
redo_count
fn redo_count(self: &Self) -> usize
set_history_limit
fn set_history_limit(self: &mut Self, limit: usize)
entry
fn entry(self: &Self, id: EntryId) -> Option<(&TranslationCatalogEntry, &EntryStatus)>
filtered_ids
fn filtered_ids(self: &Self, filter: &EntryFilter) -> Vec<EntryId>
metrics
fn metrics(self: &Self, culture: Option<&str>) -> ReviewMetrics
coverage
fn coverage(self: &Self) -> Vec<TranslationCoverage>
Distinct keys use the converter's last-entry-wins rule. Missing keys count.
set_target
fn set_target(self: &mut Self, id: EntryId, value: impl Into<String>) -> Result<bool, StudioError>
set_notes
fn set_notes(self: &mut Self, id: EntryId, notes: Option<String>) -> Result<bool, StudioError>
set_review
fn set_review(self: &mut Self, id: EntryId, review: TranslationReviewState) -> Result<bool, StudioError>
replace_entry
fn replace_entry(self: &mut Self, id: EntryId, value: TranslationCatalogEntry, review: TranslationReviewState) -> Result<bool, StudioError>
add_entry
fn add_entry(self: &mut Self, entry: TranslationCatalogEntry) -> Result<EntryId, StudioError>
delete_entry
fn delete_entry(self: &mut Self, id: EntryId) -> Result<(), StudioError>
add_target_culture
fn add_target_culture(self: &mut Self, culture_name: &str, display_name: impl Into<String>) -> Result<bool, StudioError>
set_target_culture
fn set_target_culture(self: &mut Self, culture: &str) -> Result<bool, StudioError>
export
fn export(self: &Self, format: TranslationFileFormat, options: &TranslationFormatOptions) -> Result<TranslationExportResult, StudioError>
Export the normalized catalog with its original native format states.
For Studio review states, explicitly export catalog_with_review_states()
through CatalogGateway; its generic states may incur format-loss warnings.
materialize_target_culture
fn materialize_target_culture(self: &mut Self, culture: &str) -> Result<Vec<EntryId>, StudioError>
Add missing rows for a target culture without replacing existing work. Source/context/plural metadata is copied from the last normalized key; new values and original file review states are cleared.
catalog_with_review_states
fn catalog_with_review_states(self: &Self) -> TranslationCatalog
Explicit review-state projection for workflows that want Studio approvals in the exchange file. The preserved source catalog remains unchanged.
entry_diagnostics
fn entry_diagnostics(self: &Self, id: EntryId) -> Result<Vec<String>, StudioError>
transaction
fn transaction<R>(self: &mut Self, action: impl FnOnce(&mut Self) -> Result<R, StudioError>) -> Result<R, StudioError>
One history record for a set of edits. Failed edits leave the document intact.
undo
fn undo(self: &mut Self) -> Result<bool, StudioError>
redo
fn redo(self: &mut Self) -> Result<bool, StudioError>
prepare_translation
fn prepare_translation(self: &Self, ids: &[EntryId], context: impl Into<String>) -> Result<TranslationPlan, StudioError>
prepare_missing_translations
fn prepare_missing_translations(self: &Self, context: impl Into<String>) -> Result<TranslationPlan, StudioError>
accept_suggestion
fn accept_suggestion(self: &mut Self, suggestion: &TranslationSuggestion) -> Result<bool, StudioError>
accept_suggestions
fn accept_suggestions(self: &mut Self, suggestions: &[TranslationSuggestion]) -> Result<usize, StudioError>
The whole accepted batch is one undo operation. Any stale suggestion rejects the batch before writing, so a later edit can never be lost.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEither
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.