use std::path::Path;
use crate::companion::title_from_markdown;
use crate::{CompanionFile, Result};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CompanionDiscovery {
Beside,
Ancestors,
DocsSubdir,
}
pub trait CompanionStrategy: Send + Sync {
fn discovery(&self) -> CompanionDiscovery;
fn output_name(&self, source_dir: &[&str], stem: &str) -> String;
fn companion_media_types(&self) -> &'static [&'static str];
fn companion_title(&self, stem: &str, bytes: &[u8]) -> String {
title_from_markdown(stem, bytes)
}
fn discover_local(&self, contract_root: &Path) -> Result<Vec<CompanionFile>> {
let _ = contract_root;
Ok(Vec::new())
}
}
pub trait AsyncCompanionStrategy: Send + Sync {
fn discovery(&self) -> CompanionDiscovery;
fn output_name(&self, source_dir: &[&str], stem: &str) -> String;
fn companion_media_types(&self) -> &'static [&'static str];
fn companion_title(&self, stem: &str, bytes: &[u8]) -> String {
title_from_markdown(stem, bytes)
}
async fn discover(&self, contract_root: &Path) -> Result<Vec<CompanionFile>>;
}