mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-06 05:04:18 +00:00
backends: implement as_any() on OpStore and OpHeadsStore too
It's useful for custom commands to be able to downcast to custom backend types.
This commit is contained in:
parent
cfcc7c5e34
commit
7c87fe243c
4 changed files with 16 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::HashSet;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
@ -35,6 +36,8 @@ pub trait OpHeadsStoreLock {}
|
|||
|
||||
/// Manages the set of current heads of the operation log.
|
||||
pub trait OpHeadsStore: Send + Sync + Debug {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
fn name(&self) -> &str;
|
||||
|
||||
/// Remove the old op heads and add the new one.
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fmt::{Debug, Error, Formatter};
|
||||
use std::iter;
|
||||
|
@ -434,6 +435,8 @@ pub enum OpStoreError {
|
|||
pub type OpStoreResult<T> = Result<T, OpStoreError>;
|
||||
|
||||
pub trait OpStore: Send + Sync + Debug {
|
||||
fn as_any(&self) -> &dyn Any;
|
||||
|
||||
fn name(&self) -> &str;
|
||||
|
||||
fn root_operation_id(&self) -> &OperationId;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -71,6 +72,10 @@ struct SimpleOpHeadsStoreLock {
|
|||
impl OpHeadsStoreLock for SimpleOpHeadsStoreLock {}
|
||||
|
||||
impl OpHeadsStore for SimpleOpHeadsStore {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
Self::name()
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::io::{ErrorKind, Write};
|
||||
|
@ -94,6 +95,10 @@ impl SimpleOpStore {
|
|||
}
|
||||
|
||||
impl OpStore for SimpleOpStore {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
Self::name()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue