github.com/LanceLRQ/deer-common@v0.0.9-0.20210319081233-e8222ac018a8/provider/rust.go (about)

     1  package provider
     2  
     3  import "fmt"
     4  
     5  type RustCompileProvider struct {
     6  	CodeCompileProvider
     7  }
     8  
     9  func NewRustCompileProvider() *RustCompileProvider {
    10  	return &RustCompileProvider{
    11  		CodeCompileProvider{
    12  			isReady:  false,
    13  			realTime: false,
    14  			Name:     "rust",
    15  		},
    16  	}
    17  }
    18  
    19  func (prov *RustCompileProvider) Init(code string, workDir string) error {
    20  	prov.codeContent = code
    21  	prov.workDir = workDir
    22  
    23  	err := prov.checkWorkDir()
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	err = prov.initFiles(".rs", "")
    29  	return err
    30  }
    31  
    32  func (prov *RustCompileProvider) Compile() (result bool, errmsg string) {
    33  	result, errmsg = prov.shell(fmt.Sprintf(CompileCommands.Rust, prov.codeFilePath, prov.programFilePath))
    34  	if result {
    35  		prov.isReady = true
    36  	}
    37  	return
    38  }
    39  
    40  func (prov *RustCompileProvider) GetRunArgs() (args []string) {
    41  	args = []string{prov.programFilePath}
    42  	return
    43  }
    44  
    45  func (prov *RustCompileProvider) IsCompileError(remsg string) bool {
    46  	return false
    47  }