feat(domain): add TabFetcherPort and TabParserPort traits

This commit is contained in:
2026-04-08 01:35:55 +02:00
parent d004698923
commit 2f703fbb2a
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
use std::path::PathBuf;
use thiserror::Error;
use async_trait::async_trait;
use crate::song::Song;
#[derive(Debug, Clone)]
pub enum TabSource {
File(PathBuf),
Url(String),
}
#[derive(Debug, Error)]
pub enum FetchError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Network error: {0}")]
Network(String),
#[error("Response is not HTML")]
InvalidContentType,
}
#[derive(Debug, Error)]
pub enum ParseError {
#[error("Tab content not found in HTML")]
MissingContent,
#[error("Malformed HTML: {0}")]
MalformedHtml(String),
}
#[async_trait]
pub trait TabFetcherPort: Send + Sync {
async fn fetch(&self, source: TabSource) -> Result<String, FetchError>;
}
pub trait TabParserPort: Send + Sync {
fn parse(&self, html: &str) -> Result<Song, ParseError>;
}