StoreBackEnd/pkg/protocol/rules/writers/EraseErrorRule.go
2022-03-13 15:49:06 +01:00

46 lines
1.0 KiB
Go

package writers
import (
"StoreBackEnd/pkg/protocol"
)
//EraseErrorRulePrefix Rule command prefix
const EraseErrorRulePrefix = "ERASE_ERROR"
// EraseErrorRule Storage structure for the EraseErrorRule
type EraseErrorRule struct {
// cmd Rule name
cmd string
// matcher Allow to make a regex match
matcher *protocol.RegexMatcher
}
// CreateEraseErrorRule Creating an instance of EraseErrorRule
func CreateEraseErrorRule(pattern string) protocol.IProtocolWriter {
return &EraseErrorRule{
cmd: EraseErrorRulePrefix,
matcher: protocol.CreateRegexMatcher(pattern),
}
}
// GetCmd retrieve the command name.
func (rule EraseErrorRule) GetCmd() string {
return rule.cmd
}
// Execute the Rule with a string command.
func (rule EraseErrorRule) Execute(argsData ...string) *protocol.ProtocolWriterResult {
buildedCmd, _ := rule.matcher.Build(EraseErrorRulePrefix, argsData...)
return &protocol.ProtocolWriterResult{
Cmd: buildedCmd,
}
}
/*
func onWrite(writer *bufio.Writer) {
println("Ecriture du fichier sur le réseau")
}
*/