Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from jonasbb/html-and-evcxr-integration
Html and Evcxr integration
- Loading branch information
Showing
8 changed files
with
291 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! This modules contains traits and implementations to work within Evcxr | ||
|
||
use super::TableSlice; | ||
use super::utils::StringWriter; | ||
use std::io::Write; | ||
|
||
/// Evcxr specific output trait | ||
pub trait EvcxrDisplay { | ||
/// Print self in one or multiple Evcxr compatile types. | ||
fn evcxr_display(&self); | ||
} | ||
|
||
impl<'a, T> EvcxrDisplay for T | ||
where | ||
T: AsRef<TableSlice<'a>>, | ||
{ | ||
fn evcxr_display(&self) { | ||
let mut writer = StringWriter::new(); | ||
// Plain Text | ||
let _ = writer.write_all(b"EVCXR_BEGIN_CONTENT text/plain\n"); | ||
let _ = self.as_ref().print(&mut writer); | ||
let _ = writer.write_all(b"\nEVCXR_END_CONTENT\n"); | ||
|
||
// Html | ||
let _ = writer.write_all(b"EVCXR_BEGIN_CONTENT text/html\n"); | ||
let _ = self.as_ref().print_html(&mut writer); | ||
let _ = writer.write_all(b"\nEVCXR_END_CONTENT\n"); | ||
println!("{}", writer.as_string()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters