// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
/// An abort signal is used to abort merging. Implementations of `AbortSignal` /// can store an aborted flag, usually as an atomic integer or Boolean, set /// the flag on abort, and have `AbortSignal::aborted` return the flag's value. /// /// Since merging is synchronous, it's not possible to interrupt a merge from /// the same thread that started it. In practice, this means a signal will /// implement `Send` and `Sync`, too, so that another thread can set the /// aborted flag. /// /// The name comes from the `AbortSignal` DOM API. pubtrait AbortSignal { /// Indicates if the caller signaled to abort. fn aborted(&self) -> bool;
/// Returns an error if the caller signaled to abort. This helper makes it /// easier to use the signal with the `?` operator. fn err_if_aborted(&self) -> Result<()> { ifself.aborted() {
Err(ErrorKind::Abort.into())
} else {
Ok(())
}
}
}
/// A default signal that can't be aborted. pubstruct DefaultAbortSignal;
/// Records the time taken to build a local or remote tree, number of items /// in the tree, and structure problem counts. pubstruct TreeStats { pub time: Duration, pub items: usize, pub deletions: usize, pub problems: ProblemCounts,
}
/// A merge driver provides methods to customize merging behavior. pubtrait Driver { /// Generates a new GUID for the given invalid GUID. This is used to fix up /// items with GUIDs that Places can't store (bug 1380606, bug 1313026). /// /// The default implementation returns an error, forbidding invalid GUIDs. /// /// Implementations of `Driver` can either use the `rand` and `base64` /// crates to generate a new, random GUID (9 bytes, Base64url-encoded /// without padding), or use an existing method like Desktop's /// `nsINavHistoryService::MakeGuid`. Dogear doesn't generate new GUIDs /// automatically to avoid depending on those crates. /// /// Implementations can also return `Ok(invalid_guid.clone())` to pass /// through all invalid GUIDs, as the tests do. fn generate_new_guid(&self, invalid_guid: &Guid) -> Result<Guid> {
Err(ErrorKind::InvalidGuid(invalid_guid.clone()).into())
}
/// Returns the maximum log level for merge messages. The default /// implementation returns the `log` crate's global maximum level. fn max_log_level(&self) -> LevelFilter {
log::max_level()
}
/// Returns a logger for merge messages. /// /// The default implementation returns the `log` crate's global logger. /// /// Implementations can override this method to return a custom logger, /// where using the global logger won't work. For example, Firefox Desktop /// has an existing Sync logging setup outside of the `log` crate. fn logger(&self) -> &dyn Log {
log::logger()
}
/// Records a merge telemetry event. /// /// The default implementation is a no-op that discards the event. /// Implementations can override this method to capture event and bookmark /// validation telemetry. fn record_telemetry_event(&self, _: TelemetryEvent) {}
}
/// A default implementation of the merge driver. pubstruct DefaultDriver;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.