mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
move migration api out of struct implementation
This commit is contained in:
parent
06f43f34f3
commit
39ee50c4ba
10
src/app.rs
10
src/app.rs
@ -233,7 +233,7 @@ impl App {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Begin migration
|
// Begin migration
|
||||||
match App::migrate(&transaction) {
|
match migrate(&transaction) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// Confirm changes
|
// Confirm changes
|
||||||
match transaction.commit() {
|
match transaction.commit() {
|
||||||
@ -248,18 +248,18 @@ impl App {
|
|||||||
// Start application
|
// Start application
|
||||||
self.gobject.run()
|
self.gobject.run()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
fn migrate(tx: &Transaction) -> Result<(), String> {
|
fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Browser::migrate(&tx)?;
|
browser::migrate(&tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -250,9 +250,10 @@ impl Browser {
|
|||||||
pub fn gobject(&self) -> &ApplicationWindow {
|
pub fn gobject(&self) -> &ApplicationWindow {
|
||||||
&self.widget.gobject()
|
&self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@ -260,11 +261,10 @@ impl Browser {
|
|||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
/* @TODO
|
/* @TODO
|
||||||
Header::migrate(&tx)?; */
|
header::migrate(&tx)?; */
|
||||||
Window::migrate(&tx)?;
|
window::migrate(&tx)?;
|
||||||
Widget::migrate(&tx)?;
|
widget::migrate(&tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -100,9 +100,10 @@ impl Widget {
|
|||||||
pub fn gobject(&self) -> &ApplicationWindow {
|
pub fn gobject(&self) -> &ApplicationWindow {
|
||||||
&self.gobject
|
&self.gobject
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@ -113,5 +114,4 @@ impl Widget {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -168,18 +168,18 @@ impl Window {
|
|||||||
pub fn gobject(&self) -> &Box {
|
pub fn gobject(&self) -> &Box {
|
||||||
&self.widget.gobject()
|
&self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Tab::migrate(&tx)?;
|
tab::migrate(&tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -335,21 +335,18 @@ impl Tab {
|
|||||||
pub fn gobject(&self) -> &TabView {
|
pub fn gobject(&self) -> &TabView {
|
||||||
self.widget.gobject()
|
self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Item::migrate(&tx)?;
|
item::migrate(&tx)?;
|
||||||
|
|
||||||
/* @TODO
|
|
||||||
Page::migrate(&tx)?; */
|
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -219,19 +219,19 @@ impl Item {
|
|||||||
pub fn gobject(&self) -> &TabPage {
|
pub fn gobject(&self) -> &TabPage {
|
||||||
&self.widget.gobject()
|
&self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Page::migrate(&tx)?;
|
page::migrate(&tx)?;
|
||||||
Widget::migrate(&tx)?;
|
widget::migrate(&tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -391,21 +391,6 @@ impl Page {
|
|||||||
&self.widget.gobject()
|
&self.widget.gobject()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tools
|
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
|
||||||
// Migrate self components
|
|
||||||
if let Err(e) = Database::init(tx) {
|
|
||||||
return Err(e.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delegate migration to childs
|
|
||||||
Meta::migrate(tx)?;
|
|
||||||
Navigation::migrate(tx)?;
|
|
||||||
|
|
||||||
// Success
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private helpers @TODO move outside
|
// Private helpers @TODO move outside
|
||||||
fn load_gemini(&self, uri: Uri) {
|
fn load_gemini(&self, uri: Uri) {
|
||||||
// Use local namespaces @TODO
|
// Use local namespaces @TODO
|
||||||
@ -938,6 +923,20 @@ impl Page {
|
|||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
|
|
||||||
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
|
// Migrate self components
|
||||||
|
if let Err(e) = Database::init(tx) {
|
||||||
|
return Err(e.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delegate migration to childs
|
||||||
|
meta::migrate(tx)?;
|
||||||
|
navigation::migrate(tx)?;
|
||||||
|
|
||||||
|
// Success
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper function, extract readable title from [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
/// Helper function, extract readable title from [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
||||||
///
|
///
|
||||||
/// Useful as common placeholder when page title could not be detected
|
/// Useful as common placeholder when page title could not be detected
|
||||||
|
@ -178,9 +178,10 @@ impl Meta {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@ -191,5 +192,4 @@ impl Meta {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -168,18 +168,18 @@ impl Navigation {
|
|||||||
pub fn request_text(&self) -> GString {
|
pub fn request_text(&self) -> GString {
|
||||||
self.request.text()
|
self.request.text()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Request::migrate(tx)?;
|
request::migrate(tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -117,18 +117,18 @@ impl Request {
|
|||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(tx) {
|
if let Err(e) = Database::init(tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegate migration to childs
|
// Delegate migration to childs
|
||||||
Widget::migrate(tx)?;
|
widget::migrate(tx)?;
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -221,9 +221,10 @@ impl Widget {
|
|||||||
pub fn text(&self) -> GString {
|
pub fn text(&self) -> GString {
|
||||||
self.gobject.text()
|
self.gobject.text()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@ -234,5 +235,4 @@ impl Widget {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,10 @@ impl Widget {
|
|||||||
pub fn gobject(&self) -> &TabPage {
|
pub fn gobject(&self) -> &TabPage {
|
||||||
&self.gobject
|
&self.gobject
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
pub fn migrate(tx: &Transaction) -> Result<(), String> {
|
||||||
// Migrate self components
|
// Migrate self components
|
||||||
if let Err(e) = Database::init(&tx) {
|
if let Err(e) = Database::init(&tx) {
|
||||||
return Err(e.to_string());
|
return Err(e.to_string());
|
||||||
@ -137,5 +138,4 @@ impl Widget {
|
|||||||
|
|
||||||
// Success
|
// Success
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user