Struct wandbox::CompilationBuilder
source · [−]pub struct CompilationBuilder {
pub lang: String,
/* private fields */
}
Expand description
A builder to allow you to easily build requests
use std::collections::HashSet;
use tokio::macros::*;
use std::error::Error;
use wandbox::{Wandbox, CompilationBuilder};
#[tokio::main]
async fn main() {
let wbox : Wandbox = match Wandbox::new(None, None).await {
Ok(wbox) => wbox,
Err(e) => return println!("{}", e)
};
let mut builder = CompilationBuilder::new();
builder.target("gcc-6.3.0");
builder.options_str(vec!["-Wall", "-Werror"]);
builder.code("#include<iostream>\nint main()\n{\nstd::cout<<\"test\";\n}");
let result = match builder.build(&wbox) {
Ok(res) => res,
Err(e) => return println!("{}", e)
};
}
Fields
lang: String
Implementations
sourceimpl CompilationBuilder
impl CompilationBuilder
sourcepub fn new() -> CompilationBuilder
pub fn new() -> CompilationBuilder
Creates a new CompilationBuilder with default values to be filled in later
sourcepub fn target(&mut self, target: &str)
pub fn target(&mut self, target: &str)
Sets the target of the compilation
Arguments
target
- The target of a compilation, this can be a language (‘c++’), or a compiler (‘gcc-head’)
sourcepub fn save(&mut self, save: bool)
pub fn save(&mut self, save: bool)
Determines whether or not Wandbox saves the compilation & replies with a link for you
Arguments
save
- true if Wandbox should save this compilation
sourcepub fn options(&mut self, options: Vec<String>)
pub fn options(&mut self, options: Vec<String>)
Sets the list of compilation options. Useful for languages like c++ to pass linker/optimization flags.
Arguments
options
- A list of compiler options i.e [“-Wall”, “-Werror”]
sourcepub fn options_str(&mut self, options: Vec<&str>)
pub fn options_str(&mut self, options: Vec<&str>)
Sets the list of compilation options. Useful for languages like c++ to pass linker/optimization flags.
This version allows you to pass a Vec<&str>
Arguments
options
- A list of compiler options i.e [“-Wall”, “-Werror”]
sourcepub fn build(&mut self, wb: &Wandbox) -> Result<(), WandboxError>
pub fn build(&mut self, wb: &Wandbox) -> Result<(), WandboxError>
Finalizes the builder & prepares itself for compilation dispatch.
Arguments
wb
- An instance of the Wandbox cache to resolve the compilation target
sourcepub async fn dispatch(&self) -> Result<CompilationResult, WandboxError>
pub async fn dispatch(&self) -> Result<CompilationResult, WandboxError>
Dispatches the built request to Wandbox
Trait Implementations
sourceimpl Default for CompilationBuilder
impl Default for CompilationBuilder
sourcefn default() -> CompilationBuilder
fn default() -> CompilationBuilder
Returns the “default value” for a type. Read more
sourceimpl Serialize for CompilationBuilder
impl Serialize for CompilationBuilder
Auto Trait Implementations
impl RefUnwindSafe for CompilationBuilder
impl Send for CompilationBuilder
impl Sync for CompilationBuilder
impl Unpin for CompilationBuilder
impl UnwindSafe for CompilationBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more