def encode_sub(self, validator, value):<EOL>
if isinstance(validator, bv.List):<EOL><INDENT>validate_f = validator.validate  <EOL>encode_f = self.encode_list  <EOL><DEDENT>elif isinstance(validator, bv.Map):<EOL><INDENT>validate_f = validator.validate<EOL>encode_f = self.encode_map<EOL><DEDENT>elif isinstance(validator, bv.Nullable):<EOL><INDENT>validate_f = validator.validate<EOL>encode_f = self.encode_nullable<EOL><DEDENT>elif isinstance(validator, bv.Primitive):<EOL><INDENT>validate_f = validator.validate<EOL>encode_f = self.encode_primitive<EOL><DEDENT>elif isinstance(validator, bv.Struct):<EOL><INDENT>if isinstance(validator, bv.StructTree):<EOL><INDENT>if self.caller_permissions.permissions:<EOL><INDENT>def validate_with_permissions(val):<EOL><INDENT>validator.validate_with_permissions(val, self.caller_permissions)<EOL><DEDENT>validate_f = validate_with_permissions<EOL><DEDENT>else:<EOL><INDENT>validate_f = validator.validate<EOL><DEDENT>encode_f = self.encode_struct_tree<EOL><DEDENT>else:<EOL><INDENT>if self.caller_permissions.permissions:<EOL><INDENT>def validate_with_permissions(val):<EOL><INDENT>validator.validate_with_permissions(val, self.caller_permissions)<EOL><DEDENT>validate_f = validate_with_permissions<EOL><DEDENT>else:<EOL><INDENT>validate_f = validator.validate_type_only<EOL><DEDENT>encode_f = self.encode_struct<EOL><DEDENT><DEDENT>elif isinstance(validator, bv.Union):<EOL><INDENT>validate_f = validator.validate_type_only<EOL>encode_f = self.encode_union<EOL><DEDENT>else:<EOL><INDENT>raise bv.ValidationError('<STR_LIT>'.format(type(validator).__name__))<EOL><DEDENT>validate_f(value)<EOL>return encode_f(validator, value)<EOL>
Callback intended to be called by other ``encode`` methods to
delegate encoding of sub-values. Arguments have the same semantics
as with the ``encode`` method.